Name
ServletContext
Synopsis
Interface Name: javax.servlet.ServletContext
Superinterface: None
Immediate Subinterfaces: None
Implemented By: None
Availability: Servlet API 1.0 and later
Description
The ServletContext interface defines a set of
methods that can be used to communicate with the server in a
non-request-specific manner. This includes finding path information,
accessing other servlets running on the server, and writing to the
server log file. Different virtual servers may return different
servlet contexts.
Interface Declaration
public interface ServletContext {
// Methods
public abstract Object getAttribute(String name);
public abstract String getMimeType(String file);
public abstract String getRealPath(String path);
public abstract String getServerInfo();
public abstract Servlet getServlet(String name) throws ServletException;
public abstract Enumeration getServletNames(); // New in 2.0
public abstract Enumeration getServlets(); // Deprecated
public abstract void log(Exception exception, String msg); // New in 2.0
public abstract void log(String msg);
}Methods
getAttribute()
public abstract Object getAttribute(String name)
- Description
Returns the value of the named server attribute as an
Objectornullif the attribute does not exist. The attributes are server-dependent and allow web servers to provide servlets with information above and beyond that provided for by the base Servlet API. Attribute names should follow the same convention as package names. The package namesjava.*