The application of JSP

Source: Internet
Author: User

1, session: A client during the visit to the site sharing

2. Application: Shared during multiple client access sites

3, PageContext: sharing between a page

4. Equest: Request

Application.setattribute ("attribute name", "attribute value");

Application.getattribute ("attribute name");

Application.removeattribute ("attribute name");

Application.getattributenames (); The return data type is: Enumeration

Getmajorversion

Function: Returns the latest Seervlet API version supported by the server interpretation engine

GetMimeType (String file)

Function: Return file file format and encoding method;

Getrealpath (String Path)

Function: Returns the true path of the virtual path path;

Getserverinfo ()

Function: Returns information about the server interpretation engine

5. Enumeration interface

Only the following two methods are defined in the Enumertion interface.
Boolean hasmoreelemerts ()
Tests whether the enumeration enumeration object also contains elements, and if true, indicates that there are at least one element.
· Object nextelement ()
If the Bnumeration enumeration object also contains elements, the method obtains the next element in the object.

Ready for work.

Now achieve the statistics of the site traffic, and also to print out the site of all visitors SessionID

<span style= "FONT-SIZE:18PX;" ><%@ page import= "java.util.*" contenttype= "Text/html;charset=utf-8"%><%! int numbers = 0;%><%! Public synchronized void Countpeople () {        numbers++;} %><%        if (session.isnew ()) {                countpeople ();                String str = string.valueof (numbers);                Session.setattribute ("Count", str);        }        Application.setattribute (Session.getid (), integer.tostring (numbers));        Enumeration E = Application.getattributenames ();        while (E.hasmoreelements ()) {                out.println (e.nextelement (). toString () + "<br>");        } %>

The problem arises: the start does not reference java.util.* this package, resulting in enumeration not available. You should pay attention to the package when you write it later.

The application of JSP

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.