Using JSP Scriptlet XML Tag

jsp tutorial
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

// code to be written in the scriptlet

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


    This is in the html body
    out.println("This is in the scriptlet");

Posted by at on

Tags: Java Server Pages,