JAVA Web application objects

Global Application Object application

  • Sesion objects of different users different from each other, but may take between a user 共享对象, when the object was launched after the Web server creates a unique built-in objects such application.
  • Any user accessing the same Web services directory of each page, a shared application objects until the server is shut down, the application object is canceled.
  • application object data can also be stored.
  • application objects are valid in the entire application area, while the session is only valid within the scope of the current client session, when more than save time were recovered.

application access to the application initialization parameters

  • application object provides a method for application initialization parameters for access.
  • Application Initialization parameters set in web.xml file, web.xml file located in a subdirectory under WEB-INF directory of the Web application resides. In web.xml file initialization parameter table level by the configuration application. ( ???)

Property management application environment

  • Get all the properties of the application object names 枚举对象:
public Enumeration getAttributeNames()
  • Gets the specified object name from the application object
public Object getAttribute(String key)
  • Storing data objects:
public void setAttribute(String key , Object obj)
  • Remove property specifies the name of the object from the application
public void removeAttribute(String key , Object obj)



application object methods family bucket

 Object getAttribute(String name):返回给定名的属性值。
 Enumeration getAttributeNames():返回所有可用属性名的枚举。
 void setAttribute(String name,Object obj):设定属性的属性值。
 void removeAttribute(String name) :删除一属性及其属性值。
 String getServerInfo():返回JSP(SERVLET)引擎名及版本号。
 String getRealPath(String path) :返回一虚拟路径的真实路径。
 ServletContext getContext(String uripath) :返回指定WebApplication的application对象。
 int getMajorVersion():返回服务器支持的Servlet API的最大版本号。
 int getMinorVersion():返回服务器支持的Servlet API的最大版本号。
 String getMimeType(String file):返回指定文件的MIME类型。
 URL getResource(String path):返回指定资源(文件及目录)URL路径。
 InputStream getResourceAsStream(String path):返回指定资源的输入流。
 RequestDispatcher getRequestDispatcher(String uripath):返回指定资源RequestDispatcher对象。
 Servlet getServlet(String name):返回指定名的Servlet。
 Enumeration getServlets():返回所有Servlet的枚举。
 Enumeration getServletNames():返回所有Servlet名的枚举。
 void log(String msg):把指定消息写入Servlet的日志文件。
 void log(Exception exception,String msg):把指定异常的栈轨迹和错误消息写入Servlet的日志文件。
 void log(String msg,Throwable throwable):把栈轨迹和给出的Throwable异常的说明信息写入到Servlet
的日志文件。

Left to record, tomorrow to resolve.

  • sendMessage () how to use

https://blog.csdn.net/qq_29656961/article/details/78125164 //

Published 22 original articles · won praise 0 · Views 151

Guess you like

Origin blog.csdn.net/weixin_42649617/article/details/104850358