Application Object in JSP

Source: Internet
Author: User

1. application is a "global context" object that can be used in JSP, which is equivalent to a "global access zone" in an application, as long as data is put into the application. setAttribute ("key", "value");), which can be used anywhere. getAttribute ("key. It is combined with request, session, and application as three context objects!

 

2. The method obtained in Servlet is as follows: ServletContext appliation = this. getServletContext ();

 

3. Another use of the application object is that it can obtain application-related data, such:

 

Application. getRealPath ("/"); to obtain the actual absolute path after the project is published to the server.

 

4. application. getInitParameter ("name");, you can obtain the following data in web. xml:

<Context-parameter>

<Parameter-name> name </parameter-name>

<Parmeter-value> available data </parameter-value>

</Context-parameter>

 

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.