10.3. JSP Scriptlets
If you want to do something more complex than insert a simple expression, JSP scriptlets let you insert arbitrary code into the servlet's _jspService method (which is called by service). Scriptlets have the following form:
<% Java Code %>
Scriptlets have access to the same automatically defined variables as expressions (request, response, session, out, etc.; see Section 10.5). So, for example, if you want output to appear in the resultant page, you would use the out variable, as in the following example.
<% String queryData = request.getQueryString(); out.println("Attached GET data: " + queryData); %>
In this particular instance, you could have accomplished the same effect more easily by using the following JSP expression: ...
Get Core Servlets and JavaServer Pages™ now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.