Application understanding and use

Source: Internet
Author: User

Description: This instance represents the WEB application itself that the JSP belongs to, for use in JSP pages, or for information exchange between Servlets. Common methods are getattribute (name, value), SetAttribute (name, value), Getinitparameter (name), and so on.

Instance:

Declare a variable i on the a.jsp page and put this value in application named "Counter"

<%! int i; %>

<%application.setattribute ("Counter", String.valueof (++i));%>

After you put application, you can invoke the value of "counter" on any page.
<%=application.getattribute ("Counter")%>


Application also has an important purpose: the configuration parameters that can be used to obtain the Web application (XML).

Use the <context-param> element configuration in the Web. xml file, and parameters <param-name> <param-value> for example:

in the JSP page, you can use application to take out parameters:

In this way, some information can be configured in the Web. xml file to improve the portability of the program.

Application understanding and use

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.