Jsp Scripting Element

Jsp Scripting Element: These are the element which insert java code into generated servlet. Thses gets evaluated at run time and displayed on page.


Expression: It is used to insert java values directly into the output. On translation it goes to out.print statement.


   <%=request.getX() >

Points to remember:

1) You can't use semicolon to end an expression.

2) Expression evaluated left to right.

3) It can contain any expression that is valid as per java language.

Scriptlet: It is used to insert java code in -jspService method of generated servlet.

 <% if(condition){ %>
 <% else %>

Declaration: It is used to insert declaration of fields or method defination in servlet class.


  <%! Integer i =10; %>
  <%! public void a(){

It can be used to override jspInt and jspDestroy methods.