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
-
getAttribute(String)
- Gets the value of a named attribute
-
getMimeType(String)
- Gives the mimetype of the requested file
-
getRealPath(String)
- Translates the requested virtual path to the real filesystem path
using the servers knowledge of the document root.
-
getServerInfo()
- A server supplied string containing the server name, version number, etc
-
getServlet(String)
- Gets a specific servlet by name.
-
getServletNames()
- Gets all servlet names
-
getServlets()
- Gets all servlets
Deprecated.
-
log(Exception, String)
- Writes an exception + message to the log
-
log(String)
- Writes a message to the log
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
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
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
getServerInfo
public abstract String getServerInfo()
- A server supplied string containing the server name, version number, etc
- Returns:
- the string
log
public abstract void log(String message)
- Writes a message to the log
- Parameters:
- message - the message to write
log
public abstract void log(Exception exception,
String message)
- Writes an exception + message to the log
- Parameters:
- exception - the exception
- message - the message
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
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.
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