Share this post! | Vote this! |
|
JSP also allows you to write blocks of Java code inside the JSP.
You do this by placing your Java code between <% and
%>
characters (just like expressions, but without the = sign
at the start of the sequence.)
This block of code is known as a "scriptlet". By itself, a scriptlet doesn't contribute any HTML (though it can, as we will see down below.) A scriptlet contains Java code that is executed every time the JSP is invoked.
Here is a modified version of our JSP from previous section, adding in a scriptlet.
This block of code is known as a "scriptlet". By itself, a scriptlet doesn't contribute any HTML (though it can, as we will see down below.) A scriptlet contains Java code that is executed every time the JSP is invoked.
Here is a modified version of our JSP from previous section, adding in a scriptlet.
<HTML> <BODY> <% // This is a scriptlet. Notice that the "date" // variable we declare here is available in the // embedded expression later on. System.out.println( "Evaluating date now" ); java.util.Date date = new java.util.Date(); %> Hello! The time is now <%= date %> </BODY> </HTML> more...
0 comments:
Post a Comment