com.mortbay.HTTP.Handler
Class ServletContextWrapper

java.lang.Object
  |
  +--com.mortbay.HTTP.Handler.ServletContextWrapper

public class ServletContextWrapper
extends java.lang.Object
implements javax.servlet.ServletContext

Servlet Context wrapper class. This class wraps the context provided by the HttpServer in order to allow servlet specific resource bases


Constructor Summary
ServletContextWrapper(HttpServer context, java.lang.String resourceBase)
           
 
Method Summary
 java.lang.Object getAttribute(java.lang.String name)
          Returns an attribute of the server given the specified key name.
 java.util.Enumeration getAttributeNames()
          .
 javax.servlet.ServletContext getContext(java.lang.String url)
          Returns a ServletContext object that corresponds to a specified URL on the server.
 int getMajorVersion()
          Returns the major version of the Java Servlet API that this Web server supports.
 java.lang.String getMimeType(java.lang.String file)
          Returns the mime type of the specified file, or null if not known.
 int getMinorVersion()
          Returns the minor version of the Servlet API that this Web server supports.
 java.lang.String getRealPath(java.lang.String path)
          Applies alias rules to the specified virtual path and returns the corresponding real path.
 javax.servlet.RequestDispatcher getRequestDispatcher(java.lang.String path)
          Get a RequestDispatcher.
 java.net.URL getResource(java.lang.String path)
          Get a resource.
 java.io.InputStream getResourceAsStream(java.lang.String path)
          Get a resource as a Stream.
 java.lang.String getServerInfo()
          Returns the name and version of the Web server under which the servlet is running.
 javax.servlet.Servlet getServlet(java.lang.String name)
          Deprecated.  
 java.util.Enumeration getServletNames()
          Deprecated.  
 java.util.Enumeration getServlets()
          Deprecated. Use getServletNames & getServlet
 void log(java.lang.Exception e, java.lang.String message)
          Deprecated.  
 void log(java.lang.String message)
          Writes a message to the servlet log file.
 void log(java.lang.String message, java.lang.Throwable th)
          Writes a message to the servlet log file.
 void removeAttribute(java.lang.String name)
          .
 void setAttribute(java.lang.String name, java.lang.Object value)
          .
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ServletContextWrapper

public ServletContextWrapper(HttpServer context,
                             java.lang.String resourceBase)
Method Detail

getServlet

public javax.servlet.Servlet getServlet(java.lang.String name)
Deprecated.  

Returns the servlet for the specified name.
Specified by:
getServlet in interface javax.servlet.ServletContext
Parameters:
name - the name of the servlet
Returns:
the Servlet, or null if not found
Throws:
javax.servlet.ServletException - if the servlet could not be initialized

getServlets

public java.util.Enumeration getServlets()
Deprecated. Use getServletNames & getServlet

Enumerates the servlets in this context (server). Only servlets that are accessible will be returned. The enumeration always includes the servlet itself.
Specified by:
getServlets in interface javax.servlet.ServletContext

getServletNames

public java.util.Enumeration getServletNames()
Deprecated.  

Specified by:
getServletNames in interface javax.servlet.ServletContext

getContext

public javax.servlet.ServletContext getContext(java.lang.String url)
Description copied from interface: javax.servlet.ServletContext
Returns a ServletContext object that corresponds to a specified URL on the server.

This method allows servlets to gain access to the resources located at a specified URL and obtain RequestDispatcher objects from it.

In security conscious environments, the servlet engine can return null for a given URL.

Specified by:
getContext in interface javax.servlet.ServletContext
Tags copied from interface: javax.servlet.ServletContext
Parameters:
uripath - a String specifying the URL for which you are requesting a ServletContext object
Returns:
the ServletContext object that corresponds to the named URL
See Also:
RequestDispatcher

getMajorVersion

public int getMajorVersion()
Description copied from interface: javax.servlet.ServletContext
Returns the major version of the Java Servlet API that this Web server supports. All implementations that comply with Version 2.1 must have this method return the integer 2.
Specified by:
getMajorVersion in interface javax.servlet.ServletContext
Tags copied from interface: javax.servlet.ServletContext
Returns:
2

getMinorVersion

public int getMinorVersion()
Description copied from interface: javax.servlet.ServletContext
Returns the minor version of the Servlet API that this Web server supports. All implementations that comply with Version 2.1 must have this method return the integer 1.
Specified by:
getMinorVersion in interface javax.servlet.ServletContext
Tags copied from interface: javax.servlet.ServletContext
Returns:
1

getResource

public java.net.URL getResource(java.lang.String path)
                         throws java.net.MalformedURLException
Get a resource. This is implemented with a standard URL instance that will make a socket connection back to the server. This is less than efficient and a better implementation is provided for getResourceAsStream.
Specified by:
getResource in interface javax.servlet.ServletContext
Parameters:
path - URL path of resource
Returns:
null
Throws:
java.net.MalformedURLException -  

getResourceAsStream

public java.io.InputStream getResourceAsStream(java.lang.String path)
Get a resource as a Stream. Creates a simulated request to the local server and returns the content of the simulated response.
Specified by:
getResourceAsStream in interface javax.servlet.ServletContext
Parameters:
path - URL path of resource
Returns:
InputStream
See Also:
getResource(String path)

getRequestDispatcher

public javax.servlet.RequestDispatcher getRequestDispatcher(java.lang.String path)
Get a RequestDispatcher.
Specified by:
getRequestDispatcher in interface javax.servlet.ServletContext
Parameters:
path - URL path of resource
Returns:
null

log

public void log(java.lang.String message)
Writes a message to the servlet log file.
Specified by:
log in interface javax.servlet.ServletContext
Parameters:
message - the message to be written

log

public void log(java.lang.String message,
                java.lang.Throwable th)
Writes a message to the servlet log file.
Specified by:
log in interface javax.servlet.ServletContext
Parameters:
message - the message to be written
th - Throwable

log

public void log(java.lang.Exception e,
                java.lang.String message)
Deprecated.  

Writes an exception & message to the servlet log file.
Specified by:
log in interface javax.servlet.ServletContext
Parameters:
message - the message to be written

getRealPath

public java.lang.String getRealPath(java.lang.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.
Specified by:
getRealPath in interface javax.servlet.ServletContext
Parameters:
path - the real path to be translated

getMimeType

public java.lang.String getMimeType(java.lang.String file)
Returns the mime type of the specified file, or null if not known.
Specified by:
getMimeType in interface javax.servlet.ServletContext
Parameters:
file - file name whose mime type is required

getServerInfo

public java.lang.String getServerInfo()
Returns the name and version of the Web server under which the servlet is running. Same as the CGI variable SERVER_SOFTWARE.
Specified by:
getServerInfo in interface javax.servlet.ServletContext
Tags copied from interface: javax.servlet.ServletContext
Returns:
a String containing at least the servlet engine name and version number

getAttribute

public java.lang.Object getAttribute(java.lang.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. This implementation maps the attribute requests to properties of HttpConfiguration. The Jetty configuration does not adhere to the naming conventions described above.
Specified by:
getAttribute in interface javax.servlet.ServletContext
Parameters:
name - the attribute key name
Returns:
the value of the attribute, or null if not defined

getAttributeNames

public java.util.Enumeration getAttributeNames()
. This implementation maps the attribute requests to properties of HttpConfiguration. The Jetty configuration does not adhere to the naming conventions described above.
Specified by:
getAttributeNames in interface javax.servlet.ServletContext
Tags copied from interface: javax.servlet.ServletContext
Returns:
an Enumeration of attribute names
See Also:
ServletContext.getAttribute(java.lang.String)

setAttribute

public void setAttribute(java.lang.String name,
                         java.lang.Object value)
. This implementation maps the attribute requests to properties of HttpConfiguration. The Jetty configuration does not adhere to the naming conventions described above.
Specified by:
setAttribute in interface javax.servlet.ServletContext
Tags copied from interface: javax.servlet.ServletContext
Parameters:
name - a String specifying the name of the attribute
object - an Object representing the attribute to be given the name

removeAttribute

public void removeAttribute(java.lang.String name)
. This implementation maps the attribute requests to properties of HttpConfiguration. The Jetty configuration does not adhere to the naming conventions described above.
Specified by:
removeAttribute in interface javax.servlet.ServletContext
Tags copied from interface: javax.servlet.ServletContext
Parameters:
name - a String specifying the name of the attribute to be removed