Application is an instance of the Javax.servlet.ServletContext interface, which actually represents the context of the entire servlet.
Common methods for application objects:
The above method is application, of course, in addition to the above three methods, for the addition of attributes, acquisition and deletion has its application, setattribute (), getattribute (), RemoveAttribute ().
Let's take a study of the three methods in the table.
Get absolute path
The Getrealpath () method is used to obtain an absolute path to the virtual directory of an item. An example to look at the use and effect of this method.
application_01.jsp
<%@ page language= "java" contenttype= "text/html" pageencoding= "Utf-8"%>
Run it to find that the real path is the path to our project. But in this place it is important to note that the application operation itself is an instance of the ServletContext interface, but in the JSP, there is a very common method that can fully achieve this method. That is the Getservletcontext () method. The following procedure looks at the use of this method.
<%@ page language= "java" contenttype= "text/html" pageencoding= "Utf-8"%>