JSP built-in objects
jsp a total of nine built-in objects, these objects are created by the web container and apply to all jsp page.
Nine built-in objects as listed below:
Objects | Types of |
---|---|
out | Examples of class JspWriter |
request | Examples of the HttpServletRequest interface |
response | Examples of HttpServletResponse interface |
config | Examples of class ServletConfig |
application | Examples ServletContext Class |
session | Examples of class HttpSession |
pageContext | Examples of class PageContext |
page | Object class |
exception | Throwable |
out
For any desired data written to the cache, you can use the built-in functions JSP out, it is JspWriter object.
The servlet is written format PrintWriter out=response.getWriter();
, but can be used directly in the JSP.
request
request is an implicit object HttpServletRequest type, i.e. each JSP container is a request to create a web. It can be used to request for information, such as parameters, header information, remote address, server name, server port, content type, character encoding and so on.
It can also be used to set the range from jsp request, access and delete attributes.
response
HttpServletResponse response is a type of implicit objects. Examples HttpServletResponse i.e. each request is created by a web jsp container.
It can be used to add or operation response, for example in response redirect to another resource, transmission errors.
config
config ServletConfig type is implicit objects. This object can be used to obtain initialization parameters specific JSP pages. by the web config object is a container created for each jsp page. Usually used to obtain initialization parameters from the web.xml file.
application
In the JSP, application type ServletContext is implicit objects.
When an application or project deployed on the server, web container create only one instance of ServletContext.
This object can be used to obtain parameters from configuaration initialization file (web.xml). It can also be used to get from the application range, set or remove attributes.
session
In the JSP, session type HttpSession is implicit objects. Java developers can use this object to set, get, or delete attributes or obtain session information.
pageContext
In the JSP, pageContext type is implicit objects pageContext class. pageContext object can be used to set, get or delete one of the following range of properties:
- page
- request
- session
- application
jsp page in the range is the default page range
page
In the JSP, page object class type is implicit objects. This object is assigned to the referenced automatically generated servlet class.
page is synonymous with this method servlet class definition after the call for translation.
It is written like this: Object page=this;
In order to use this object, it must be converted to Servlet type. For example: <%(HttpServlet)page.log("message"); %>
Because it is of type Object, so it is rarely used, because you can use the object directly in the jsp. E.g:<% this.log("message"); %>
exception
In the JSP, exception type java.lang is implicit objects. Throwable class. This object can be used to print exceptions. But it can only be used for error page.
Github:
https://github.com/whyicn/JSP_implicit_object/tree/master
References:
https://www.tutorialspoint.com/jsp/jsp_syntax.htm
https://www.runoob.com/jsp/jsp-tutorial.html