Jsp implicit object ServletContext application

Domain objects can access attribute values ​​for sharing in the domain.

servletContext is the context of the container servlet, which is useful during the entire Tomcat startup process.

Application is a built-in object in jsp, equivalent to servletContext.

So the value is stored in the servletContext, we can get it in the application.

Same: In fact, servletContext and application are the same, which is equivalent to creating two variables with different names in one class. in

ServletContext in servlet is the application object. You only need to open the Servlet generated after JSP compilation

_jspService() method can see the following statement:
ServletContext application = null;

application = pageContext.getServletContext();

Difference: The difference between the two is that application is used in jsp and servletContext is used in servlet. application and page

Request session are all built-in objects in JSP, and the attribute data stored in ServletContext in the background can be used

The application object is obtained.

Java training

Guess you like

Origin blog.csdn.net/msjhw_com/article/details/109110113