The Scriplet tag allows Java to be mixed with HTML to produce dynamic content.Java code must be embedded within the <% and %> tag delimiters.Each language statement must end with a semicolon.
- <html>
- <head>
- <title> Simple JSP page </title>
- </head>
- <body>
- <h3>Embedded Java Code within a Web Page </h3>
- <p>
- <%
- for (int i=1;i<7;i++)
- {
- out.println("<H"+i+">The Size of H" + i +"</H"+i+">");
- out.println("<br>");
- }
- %>
- </body>
- </html>
Description:
- Type <% to indicate the beginning of the Scriplet tag.
- Type the applicable Java code after the <% delimiter.
- Use the out.println method to generate HTML.
- Type %> to close the Scriplet tag.
The Same program can also be written as :
- <html>
- <head>
- <title> Simple JSP page </title>
- </head>
- <body>
- <h3>Embedded Java Code within a Web Page </h3>
- <p>
- <%
- for (int i=1;i<7;i++)
- {
- %>
- <H<%=i%>>The Size of H<%=i%> </H<%=i%>>
- <br>
- <%
- }
- %>
- </body>
- </html>
No comments:
Post a Comment