The JSP pages you write are translated into servlets that process the HTTP GET and POST requests. The JSP code can access servlet information using implicit objects defined for each page. These implicit objects are pre-declared variables that you reference from the Java code on your JSP. The most commonly used objects are shown in Table 13.3.
Reference Name | Class | Description |
---|---|---|
config | javax.servlet.ServletConfig | The servlet configuration information for the page |
request | subclass of javax.servlet.ServletRequest | Request information for the current HTTP request |
session | javax.servlet.http.HttpSession | The servlet session object for the client |
out | javax.servlet.jsp.JspWriter | A subclass of java.io.Writer that is used to output text for inclusion on the Web page |
pageContext | javax.servlet.jsp.PageContext | The JSP page context used primarily when implementing custom tags (see Day 14) |
application | javax.servlet.ServletContext | The context for all Web components in the same application |
The following example rather laboriously writes the value of the name request parameter to the Web page and is another variant of the examples shown in Listings 13.1 and 13.2.
<HTML> <HEAD><TITLE>Hello</TITLE></HEAD> <BODY> <H1>Hello <% out.print(request.getParameter("name")); %></H1> </BODY> </HTML>
3.144.15.154