All Packages  Class Hierarchy  This Package  Previous  Next  Index

Interface java.servlet.ServletContext

public interface ServletContext
An interface for defining a servlet's environment. It is used by a servlet to obtain information about the environment (i.e. Web server) in which it is running.


Method Index

 o getAttribute(String)
Returns an attribute of the server given the specified key name.
 o getMimeType(String)
Returns the mime type of the specified file, or null if not known.
 o getRealPath(String)
Applies alias rules to the specified virtual path and returns the corresponding real path.
 o getServerInfo()
Returns the name and version of the Web server under which the servlet is running.
 o getServlet(String)
Returns the servlet for the specified name.
 o getServlets()
Enumerates the servlets in this context (server).
 o log(String)
Writes a message to the servlet log file.

Methods

 o getServlet
  public abstract Servlet getServlet(String name) throws ServletException
Returns the servlet for the specified name.

Parameters:
name - the name of the servlet
Returns:
the Servlet, or null if not found
Throws: ServletException
if the servlet could not be initialized
 o getServlets
  public abstract Enumeration getServlets()
Enumerates the servlets in this context (server). Only servlets that are accessible will be returned. The enumeration always includes the servlet itself.

 o log
  public abstract void log(String msg)
Writes a message to the servlet log file.

Parameters:
msg - the message to be written
 o getRealPath
  public abstract String getRealPath(String path)
Applies alias rules to the specified virtual path and returns the corresponding real path. Returns null if the translation could not be performed.

Parameters:
path - the real path to be translated
 o getMimeType
  public abstract String getMimeType(String file)
Returns the mime type of the specified file, or null if not known.

Parameters:
file - file name whose mime type is required
 o getServerInfo
  public abstract String getServerInfo()
Returns the name and version of the Web server under which the servlet is running. Same as the CGI variable SERVER_SOFTWARE.

 o getAttribute
  public abstract Object getAttribute(String name)
Returns an attribute of the server given the specified key name. This allows access to additional information about the server not already provided by the other methods in this interface. Attribute names should follow the same convention as package names, and those beginning with 'com.sun.*' are reserved for use by Sun Microsystems.

Parameters:
name - the attribute key name
Returns:
the value of the attribute, or null if not defined

All Packages  Class Hierarchy  This Package  Previous  Next  Index