Predefined Variables
request
The HttpServletRequest (1st arg to doGet)
response
The HttpServletResponse (2nd arg to doGet)
session
The HttpSession associated with the request (unless
disabled with the session attribute of the page directive)
out
The stream (of type JspWriter) used to send output to the
client
application
The ServletContext (for sharing data) as obtained via
getServletConfig().getContext().
25
JSP
www.corewebprogramming.com
JSP Scriptlets
Format
<%
Java Code
%>
Result
Code is inserted verbatim into servlet s _jspService
Example
<%
String queryData = request.getQueryString();
out.println("Attached GET data: " + queryData);
%>
<% response.setContentType("text/plain"); %>
XML compatible syntax
Java Code
26
JSP
www.corewebprogramming.com
13