ADS

Using Jsp Scriptlet Xml Tag

 The following example illustrates using  Using JSP Scriptlet XML Tag
The following example illustrates using <jsp:scriptlet> tag as an alternative for <% %> tag.
Both are one and the same while this tag is a much cleaner approach. It is like a html tag and ends as a normal HTML tag would.

The tag contains a prefix jsp which occurs before the : and the tag name is scriptlet. This is a pre-defined tag meaning, we need not load external tag libraries (aka taglibs) and these tags start with the prefix jsp. The syntax will be as follows

 <jsp:scriptlet>
// code to be written in the scriptlet
</jsp:scriptlet>

Just as you would use the normal scriptlet tags, these tags can be inserted anywhere in the HTML file.

index.jsp

 
<html>
    <body>
    This is in the html body
    <jsp:scriptlet>
    out.println("This is in the scriptlet");
    </jsp:scriptlet>
    </body>
</html>

Subscribe to receive free email updates:

ADS