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");
}
%>
Most Recent jsp Faqs
- How to get the real requested URI from inside the error page?
- Can I define a method in a JSP page?
- What is the difference between request.getParameter() and request.getAttribute()?
- What is difference between page and pageContext in JSP pages?
- How to config a JSP file in web.xml?
- What is the difference between jsp:forward and response.sendRedirect?
- How to retrieve values from HTML form input elements in JSP?
Most Viewed jsp Faqs
- How to config a JSP file in web.xml?
- What is difference between page and pageContext in JSP pages?
- How to disable browser caching for a specific JSP?
- How to retrieve values from HTML form input elements in JSP?
- What is the difference between jsp:forward and response.sendRedirect?
- What is the difference between request.getParameter() and request.getAttribute()?
- How to get the current JSP page name?