Showing posts with label Scriptlets in jsp. Show all posts
Showing posts with label Scriptlets in jsp. Show all posts

Thursday, August 22, 2013

basic Lesson 4:- Scriptlets in jsp

We have already seen how to embed Java expressions in JSP pages by putting them between the <%= and %> character sequences.
But it is difficult to do much programming just by putting Java expressions inside HTML.
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.