JSP Scriptlet tag

Scriptlet tag is a type tag used for inserting Java Code into JSP.

Notation of the Scriptlet tag is:

<% %>

To begin the Scriptlet tag, the user must add <% . Inside the Scriptlet tag, the user can add any valid Scriptlet, meaning any valid Java Code. User can write the code in between the Scriptlet tag accesses any variable or bean declared. The Scriptlet tag ends with the notation %>.

NOTE: there must be semicolon ; included at the end of each code inside the Scriptlet tag.

 

General syntax of Scriptlet Tag:


<%
statement1;
statement2;      //Valid Java Code
……….;
……….;
%>                   //end of Scriptlet tag

 

Example:

<%

     for (int p = 0; p<10; p++)

    {       

         out.print(p);   

     }

%>

Leave a Reply

Your email address will not be published. Required fields are marked *