JSP scripting elements(tags):

We can use html comment or jsp comment.
Html comment- <!-- ….-->
Jsp comment- <%--….--%>

Used for class,instance variable declaration and writing some methods.
The variables inside this does not go to the _jspService() method.
Variables work as instance variable.
<%!int i,j;String str;%>
<%!public int fun(){return 5;}%>

Used to give some java expression. One expression should be within one tag. The expression in this tag is resolved and then the result is displayed in the output. The expression in this tag should not be ended with a semicolon(;).
It goes into the _jspService() method.
<%=x%>- displays the value of x.
<%=new java.lang.Date()%>

Used to include some java code in the jsp. The code inside goes to the _jspService() method.

Note: All the scriptlets and expression code lands into the service method.

No comments:

Post a Comment