JSP – Scriptlet Tags

JSP Scriptlet Tag

  • Scriptlet tag contains the any no. of java code statements.
  • It may contain variables declaration or valid expressions.
  • When JSP is translated into servlet, java code written in the scriplet tag is moves to the _jspService() method by web container.

Syntax:

<%  java code %>

Note: Variable and methods declare in scriplet tag are not of class level declaration.

welcome.jsp:

<html>
            <head>
                        <title>Scriplet tag example</title>
            </head>
            <body>
                        <%
                                    out.println(“Sum of 10 and 20 = “);
                                    out.print(10 + 20);
                        %>
            </body>
</html>
Scroll to Top