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