JSP elements

There are three JSP elements:
  1. Scriptlets
  2. Expressions
  3. Declaration
Scriptlets:
Any valid java statements are allowed inside the scriptlets. All the statements inside the scriptlets will be placed inside the _jspService() method of translated servlet.

Syntax:
<%
-----
-----
%>

Expression :
Expression is short-cut form of out.println();
All the expressions will be converted to out.println() and will be placed inside in _jspService() method of translated servlet.


Syntax:
<%=exp %>
As example:
<%=str%> is same as out.println(str):

Declaration:
Methods definitions, blocks, constructor, class level variables are allowed inside the Declarations.
All the code inside the Declarations will be placed outside the _jspService() method of translated servlet.

Syntax:
<%!
void m1(){
----
----}
%>

0 comments :

Post a Comment