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 can 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 |
These implicit objects can be used on any JSP page. Using the date JSP shown in Listing 13.3 as an example, an alternative way of writing the date to the page is as follows:
<BIG> Today's date is <% out.print(new java.util.Date()); %> </BIG>
3.15.3.167