JSP built-in object, jsp built-in
In JSP, nine built-in objects are provided to simplify user development. These built-in objects are instantiated by containers for users and can be directly used by users instead of in Java, you must use the new keyword to instantiate an object before using it.
Nine built-in objects in JSP
No. |
Built-in object |
Type |
Description |
1 |
PageContext |
Javax. servlet. jsp. PageContext |
JSP page container |
2 |
Request |
Javax. servlet. http. HttpServletRequest |
Obtain user request information |
3 |
Response |
Javax. servlet. http. HttpServletResponse |
Response Information from the server to the client |
4 |
Session |
Javax. servlet. http. HttpSession |
Used to save information of each user |
5 |
Application |
Javax. servlet. ServletContext |
Indicates the shared information of all users. |
6 |
Config |
Javax. servlet. ServletConfig |
Server configuration to obtain initialization parameters |
7 |
Out |
Javax. servlet. jsp. JspWriter |
Page output |
8 |
Page |
Java. lang. Object |
Indicates a Servlet instance displayed from this page. |
9 |
Exception |
Java. lang. Throwable |
Indicates the exception on the JSP page, which takes effect only on the error page. |
Among the nine built-in objects above, pageContext, request, response, session, and application are commonly used.
The storage range of four attributes is provided in JSP. The attribute storage range refers to the number of pages on which a built-in object can be saved and used.
- Page: only save attributes on one page. It is invalid after redirect.
- Request: it is saved in only one request, and is still valid after server jump.
- Session: in the range of a session, no matter what type of Jump can be used, but the new browser cannot be used.
- Application: it is saved on the entire server and can be used by all users.