All Packages  Class Hierarchy  This Package  Previous  Next  Index

Interface javax.servlet.ServletContext

public interface ServletContext
A class created by the server to give servlets access to certain environment related objects and methods.
It contains standard information like the names of all the servlets, two kinds of log methods, the server name, etc.
The server can also store extra information here in the form of {String, Object} pairs. Different servlets can live in different ServletContexts, but a servlet engine can group related Servlets in the same ServletContext.
Servlet specific information can be transferred to a servlet using a class implementing the ServletConfig interface.

Version:
Servlet API 2.0

Method Index

 o getAttribute(String)
Gets the value of a named attribute
 o getMimeType(String)
Gives the mimetype of the requested file
 o getRealPath(String)
Translates the requested virtual path to the real filesystem path using the servers knowledge of the document root.
 o getServerInfo()
A server supplied string containing the server name, version number, etc
 o getServlet(String)
Gets a specific servlet by name.
 o getServletNames()
Gets all servlet names
 o getServlets()
Gets all servlets Deprecated.
 o log(Exception, String)
Writes an exception + message to the log
 o log(String)
Writes a message to the log

Methods

 o getAttribute
 public abstract Object getAttribute(String name)
Gets the value of a named attribute

Parameters:
name - the name of the attribute
Returns:
the value of the attribute or null if there is no attribute with this name
 o getMimeType
 public abstract String getMimeType(String filename)
Gives the mimetype of the requested file

Parameters:
filename - the file
Returns:
a String containing the mime type or null if the mime type cannot be determined
 o getRealPath
 public abstract String getRealPath(String virtualPath)
Translates the requested virtual path to the real filesystem path using the servers knowledge of the document root.

Parameters:
virtualPath - the path to be translated (e.g. /graphics/baby-gnu.png)
Returns:
the translated real filesystem path or null if the real system path cannot be found
 o getServerInfo
 public abstract String getServerInfo()
A server supplied string containing the server name, version number, etc

Returns:
the string
 o log
 public abstract void log(String message)
Writes a message to the log

Parameters:
message - the message to write
 o log
 public abstract void log(Exception exception,
                          String message)
Writes an exception + message to the log

Parameters:
exception - the exception
message - the message
 o getServlet
 public abstract Servlet getServlet(String name) throws ServletException
Gets a specific servlet by name. The Servlet is guaranteed to accept service requests.

Parameters:
name - the name of the wanted servlet
Returns:
null, used to return the servlet or null if not loaded.
Throws: ServletException
if a servlet related error occured
 o getServlets
 public abstract Enumeration getServlets()
Note: getServlets() is deprecated. Always returns an empty Enumeration. Only the servlet engine should have references to Servlets.

Gets all servlets

Returns:
Empty Enumeration, used to return an enumeration containing all loaded servlets including the calling servlet.
 o getServletNames
 public abstract Enumeration getServletNames()
Gets all servlet names

Returns:
Empty Enumeration, used to return an enumeration containing all loaded servlet names including the calling servlet name

All Packages  Class Hierarchy  This Package  Previous  Next  Index