Introduction to JSP built-in objects (6) Application objects

Source: Internet
Author: User

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"%>    

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.