Show TOC Start of Content Area

Background documentation Implicit Variables  Locate the document in its SAP Library structure

There are several variables that are predefined and available to JSP page developers for direct use. They represent commonly-used objects in servlets and JSP pages development, such as the request and response objects, the ServletContext and so on. They are intended to provide JSP authors with easy-to-use variables.

You can use the implicit variables within scriptlets or expressions elements in your JSP pages. It is not possible to use them in declaration elements.

Here are all implicit variables that the Java Server Pages 1.2 Specification has defined:

Implicit Variables

Variable Name

Description

request

This variable represents the javax.servlet.http.HttpServletRequest object that has been passed to the service method of the instance of the JSP implementation class. You can use the methods that this object defines in your JSP page to retrieve client request parameters, headers, request type, and so on.

response

This variable represents the javax.servlet.http.HttpServletResponse object that has been passed to the service method of the instance of the JSP implementation class.

Caution

You cannot use the response.getOutputStream() method in your JSP page. The reason for this is that the Web Container uses the JspWriter object (which uses response.getWriter() and the two methods cannot be invoked on the same response object as defined by the specification) to write the response content to the stream by default.

out

This variable represents the javax.servlet. jsp.JspWriter object that provides methods to send response body output to clients. This object also provides buffering of response output.

session

This variable represents the HttpSession object that is associated with the current client request. You can use methods of this object to retrieve session attributes, or set any attributes to it, as described in HTTP Sessions. 

Note

The session variable is available by default (that is, it is instantiated with the getSession(true) method, which always creates the session object when it does not exist). However, if you have specified that no sessions are required by your JSP page (by setting the session attribute of the page directive to false), the session variable is not available. If you use it in this case, the result will be a translation time error.

application

This variable represents the javax.servlet.ServletContext object. You can use it to access objects that are available in the scope of a Web application.

config

This variable represents the javax.servlet.ServletConfig object. You can use it to provide access to the initialization parameters of a servlet.

page

This variable represents an instance of the implementation class that was generated from the current JSP page. It is equivalent to the Java this keyword.

 

 

 

End of Content Area