Java Reference
In-Depth Information
Hello <B><%= getName() %></B>
</BODY>
</HTML>
When this document is initially requested, the JSP code is converted to servlet code and the
previous expression is resolved and placed in its referenced location of the generated servlet's
_jspService() method. The generated servlet would look similar to the following code snip-
pet:
// begin
out.write(“<HTML>\r\n<BODY>\r\n\r\n”);
// end
// begin
out.write(“\r\n”);
// end
// begin
out.write(“\r\n\r\nHello <B>”);
// end
// begin [file=”D:\\Expressions.jsp”;from=(6,12);to=(6,23)]
out.print( getName() );
// end
// begin
out.write(“</B>\r\n\r\n</BODY>\r\n</HTML>\r\n”);
// end
Scriptlets
Scriptlets are what bring all the scripting elements together. They can contain any coding state-
ments that are valid for the language referenced in the language directive. They are executed at
request time and they can make use of declarations, expressions, and JavaBeans. The syntax
for a scriptlet is as follows:
<% scriptlet source %>
During the initial request, the JSP scripting code is converted to servlet code and then com-
piled and loaded into resident memory. The actual source code, which is found between script-
let tags <% ... %> , is placed into the newly created servlet's _jspService() method. See the
following sample JSP source:
<HTML>
<BODY>
<% out.println(“HELLO JSP WORLD”); %>
Search WWH ::




Custom Search