javaweb built-in objects application objects

application server is responsible for the creation, application objects under each Web service directory
for all users to access the service catalog is shared, but the application in different directories of Web services interoperability
is not the same .application began to start the server, the server terminates at the close . In any place of
operations application properties, it will affect other users of this operation.
Here Insert Picture Description
1, public void setAttribute (String key , Object obj) application object can call this
method to add parameters Object obj specified object to the application object, and the object is added refers
set a keyword index.
2, public Object getAttribute (String key ) Gets an object containing the keyword application is
key objects.
3, public Enumeration getAttributeNames () generates a enumeration object, the enumeration object
keyword nextElemets () traversing the application objects corresponding to respective
sample code:
<% @ Page Import = "java.util.Enumeration"%>
< Page @ Language =% "Java" contentType = "text / HTML; charset = UTF-. 8"
the pageEncoding = "UTF-. 8"%>

application主页面

Welcome to the built-in objects Application

<% Application.setAttribute ( "usname", "fy"); application.setAttribute ( "password", "123"); application.setAttribute ( "E-mail", "[email protected]");%> user name: <% = application.getAttribute ( "usename")%>
file application properties: <% Enumeration attributes; attributes = application.getAttributeNames (); while (attributes.hasMoreElements ()) {out.println (attributes.nextElement () + "!");}%> [inserted here described image] (https://img-blog.csdnimg.cn/20190605110745558.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3dlaXhpbl80MzIzMjQyMw== , size_16, color_FFFFFF, t_70) can see the built-in attributes, and attribute username and E-mail our own to add.

Guess you like

Origin blog.csdn.net/weixin_43232423/article/details/90899028