FAQ


Advertisement



What are implicit objects in JSP?

Implicit objects are a set of Java objects that the JSP Container makes available to developers in each page. These objects may be accessed as built-in variables via scripting elements and can also be accessed programmatically by JavaBeans and Servlets. You may already meet one of these objects already - the out object which allows you to send information to the output stream.

The implicit objects are created automatically for you within the service method. Furthermore, as summarized below, each object must adhere to a specific Java class or interface definition.

Object Class or Interface Description & Scope
request http.HttpServletRequest Data included with the HTTP Request. request scope.
response http.HttpServletResponse HTTP Response data, e.g. cookies. page scope.
pageContext jsp.pageContext Provides access to all the namespaces associated with a JSP page and access to several page attributes. page scope.
session http.HttpSession User specific session data. session scope.
application ServletContext Data shared by all application pages. application scope.
out jsp.JspWriter Output stream for page context. page scope.
config ServletConfig Servlet configuration information. page scope.
page jsp.HttpJspPage Page's servlet instance. page scope.

Note that the implicit variables are only available within the jspService method and thus are not available within any declarations. Thus for example the following code will cause a compile time error.

<%!
public void amethod(){
out.print("Hello");
}
%>


Printer-friendly version Printer-friendly version | Send this 
article to a friend Mail this to a friend

Previous Next vertical dots separating previous/next from contents/index/pdf Contents

  |   |