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.

Types:

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

e.g:

   <%=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.

e.g:
 <% if(condition){ %>
   <b>True</b>
 <% else %>
   <b>false</b>

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

e.g:

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

It can be used to override jspInt and jspDestroy methods.