JspCServletContext (Tomcat API Documentation)
Keywords: org.apache.jasper.servlet.JspCServletContext class

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.apache.jasper.servlet
Class JspCServletContext

    java.lang.Object
      org.apache.jasper.servlet.JspCServletContext

All Implemented Interfaces:
  javax.servlet.ServletContext

    public class JspCServletContext

extends java.lang.Object
implements javax.servlet.ServletContext

Simple `ServletContext` implementation without HTTP-specific methods.

Author:
  Peter Rossbach (pr@webapp.de)

Field Summary
`protected java.util.Hashtable` | `myAttributes` Servlet context attributes.
`protected java.io.PrintWriter` | `myLogWriter` The log writer we will write log messages to.
`protected java.net.URL` | `myResourceBaseURL` The base URL (document root) for this context.

Constructor Summary
`JspCServletContext(java.io.PrintWriter aLogWriter, java.net.URL aResourceBaseURL)` Create a new instance of this ServletContext implementation.

Method Summary
`java.lang.Object` | `getAttribute(java.lang.String name)` Return the specified context attribute, if any.
`java.util.Enumeration` | `getAttributeNames()` Return an enumeration of context attribute names.
`javax.servlet.ServletContext` | `getContext(java.lang.String uripath)` Return the servlet context for the specified path.
`java.lang.String` | `getContextPath()` Return the context path.
`java.lang.String` | `getInitParameter(java.lang.String name)` Return the specified context initialization parameter.
`java.util.Enumeration` | `getInitParameterNames()` Return an enumeration of the names of context initialization parameters.
`int` | `getMajorVersion()` Return the Servlet API major version number.
`java.lang.String` | `getMimeType(java.lang.String file)` Return the MIME type for the specified filename.
`int` | `getMinorVersion()` Return the Servlet API minor version number.
`javax.servlet.RequestDispatcher` | `getNamedDispatcher(java.lang.String name)` Return a request dispatcher for the specified servlet name.
`java.lang.String` | `getRealPath(java.lang.String path)` Return the real path for the specified context-relative virtual path.
`javax.servlet.RequestDispatcher` | `getRequestDispatcher(java.lang.String path)` Return a request dispatcher for the specified context-relative path.
`java.net.URL` | `getResource(java.lang.String path)` Return a URL object of a resource that is mapped to the specified context-relative path.
`java.io.InputStream` | `getResourceAsStream(java.lang.String path)` Return an InputStream allowing access to the resource at the specified context-relative path.
`java.util.Set` | `getResourcePaths(java.lang.String path)` Return the set of resource paths for the "directory" at the specified context path.
`java.lang.String` | `getServerInfo()` Return descriptive information about this server.
`javax.servlet.Servlet` | `getServlet(java.lang.String name)` Deprecated. This method has been deprecated with no replacement
`java.lang.String` | `getServletContextName()` Return the name of this servlet context.
`java.util.Enumeration` | `getServletNames()` Deprecated. This method has been deprecated with no replacement
`java.util.Enumeration` | `getServlets()` Deprecated. This method has been deprecated with no replacement
`void` | `log(java.lang.Exception exception, java.lang.String message)` Deprecated. Use log(String,Throwable) instead
`void` | `log(java.lang.String message)` Log the specified message.
`void` | `log(java.lang.String message, java.lang.Throwable exception)` Log the specified message and exception.
`void` | `removeAttribute(java.lang.String name)` Remove the specified context attribute.
`void` | `setAttribute(java.lang.String name, java.lang.Object value)` Set or replace the specified context attribute.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### myAttributes

    protected java.util.Hashtable myAttributes

  Servlet context attributes.

### myLogWriter

    protected java.io.PrintWriter myLogWriter

  The log writer we will write log messages to.

### myResourceBaseURL

    protected java.net.URL myResourceBaseURL

  The base URL (document root) for this context.

Constructor Detail

### JspCServletContext

    public JspCServletContext(java.io.PrintWriter aLogWriter,
                              java.net.URL aResourceBaseURL)

  Create a new instance of this ServletContext implementation.

  Parameters:
    `aLogWriter` - PrintWriter which is used for `log()` calls
    `aResourceBaseURL` - Resource base URL

Method Detail

### getAttribute

    public java.lang.Object getAttribute(java.lang.String name)

  Return the specified context attribute, if any.

  Specified by:
    `getAttribute` in interface `javax.servlet.ServletContext`
  Parameters:
    `name` - Name of the requested attribute
  Returns:
    an `Object` containing the value of the attribute, or `null` if no attribute exists matching the given name
  See Also:
    `ServletContext.getAttributeNames()`

### getAttributeNames

    public java.util.Enumeration getAttributeNames()

  Return an enumeration of context attribute names.

  Specified by:
    `getAttributeNames` in interface `javax.servlet.ServletContext`
  Returns:
    an `Enumeration` of attribute names
  See Also:
    `ServletContext.getAttribute(java.lang.String)`

### getContext

    public javax.servlet.ServletContext getContext(java.lang.String uripath)

  Return the servlet context for the specified path.

  Specified by:
    `getContext` in interface `javax.servlet.ServletContext`
  Parameters:
    `uripath` - Server-relative path starting with '/'
  Returns:
    the `ServletContext` object that corresponds to the named URL, or null if either none exists or the container wishes to restrict this access.
  See Also:
    `RequestDispatcher`

### getContextPath

    public java.lang.String getContextPath()

  Return the context path.

  Specified by:
    `getContextPath` in interface `javax.servlet.ServletContext`

### getInitParameter

    public java.lang.String getInitParameter(java.lang.String name)

  Return the specified context initialization parameter.

  Specified by:
    `getInitParameter` in interface `javax.servlet.ServletContext`
  Parameters:
    `name` - Name of the requested parameter
  Returns:
    a `String` containing at least the servlet container name and version number
  See Also:
    `ServletConfig.getInitParameter(java.lang.String)`

### getInitParameterNames

    public java.util.Enumeration getInitParameterNames()

  Return an enumeration of the names of context initialization parameters.

  Specified by:
    `getInitParameterNames` in interface `javax.servlet.ServletContext`
  Returns:
    an `Enumeration` of `String` objects containing the names of the context's initialization parameters
  See Also:
    `ServletConfig.getInitParameter(java.lang.String)`

### getMajorVersion

    public int getMajorVersion()

  Return the Servlet API major version number.

  Specified by:
    `getMajorVersion` in interface `javax.servlet.ServletContext`
  Returns:
    2

### getMimeType

    public java.lang.String getMimeType(java.lang.String file)

  Return the MIME type for the specified filename.

  Specified by:
    `getMimeType` in interface `javax.servlet.ServletContext`
  Parameters:
    `file` - Filename whose MIME type is requested
  Returns:
    a `String` specifying the file's MIME type

### getMinorVersion

    public int getMinorVersion()

  Return the Servlet API minor version number.

  Specified by:
    `getMinorVersion` in interface `javax.servlet.ServletContext`
  Returns:
    5

### getNamedDispatcher

    public javax.servlet.RequestDispatcher getNamedDispatcher(java.lang.String name)

  Return a request dispatcher for the specified servlet name.

  Specified by:
    `getNamedDispatcher` in interface `javax.servlet.ServletContext`
  Parameters:
    `name` - Name of the requested servlet
  Returns:
    a `RequestDispatcher` object that acts as a wrapper for the named servlet, or `null` if the `ServletContext` cannot return a `RequestDispatcher`
  See Also:
    `RequestDispatcher`, `ServletContext.getContext(java.lang.String)`, `ServletConfig.getServletName()`

### getRealPath

    public java.lang.String getRealPath(java.lang.String path)

  Return the real path for the specified context-relative virtual path.

  Specified by:
    `getRealPath` in interface `javax.servlet.ServletContext`
  Parameters:
    `path` - The context-relative virtual path to resolve
  Returns:
    a `String` specifying the real path, or null if the translation cannot be performed

### getRequestDispatcher

    public javax.servlet.RequestDispatcher getRequestDispatcher(java.lang.String path)

  Return a request dispatcher for the specified context-relative path.

  Specified by:
    `getRequestDispatcher` in interface `javax.servlet.ServletContext`
  Parameters:
    `path` - Context-relative path for which to acquire a dispatcher
  Returns:
    a `RequestDispatcher` object that acts as a wrapper for the resource at the specified path, or `null` if the `ServletContext` cannot return a `RequestDispatcher`
  See Also:
    `RequestDispatcher`, `ServletContext.getContext(java.lang.String)`

### getResource

    public java.net.URL getResource(java.lang.String path)
                             throws java.net.MalformedURLException

  Return a URL object of a resource that is mapped to the specified context-relative path.

  Specified by:
    `getResource` in interface `javax.servlet.ServletContext`
  Parameters:
    `path` - Context-relative path of the desired resource
  Returns:
    the resource located at the named path, or `null` if there is no resource at that path
  Throws:
    `java.net.MalformedURLException` - if the resource path is not properly formed

### getResourceAsStream

    public java.io.InputStream getResourceAsStream(java.lang.String path)

  Return an InputStream allowing access to the resource at the specified context-relative path.

  Specified by:
    `getResourceAsStream` in interface `javax.servlet.ServletContext`
  Parameters:
    `path` - Context-relative path of the desired resource
  Returns:
    the `InputStream` returned to the servlet, or `null` if no resource exists at the specified path

### getResourcePaths

    public java.util.Set getResourcePaths(java.lang.String path)

  Return the set of resource paths for the "directory" at the specified context path.

  Specified by:
    `getResourcePaths` in interface `javax.servlet.ServletContext`
  Parameters:
    `path` - Context-relative base path
  Returns:
    a Set containing the directory listing, or null if there are no resources in the web application whose path begins with the supplied path.

### getServerInfo

    public java.lang.String getServerInfo()

  Return descriptive information about this server.

  Specified by:
    `getServerInfo` in interface `javax.servlet.ServletContext`
  Returns:
    a `String` containing at least the servlet container name and version number

### getServlet

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

  Deprecated. This method has been deprecated with no replacement

  Return a null reference for the specified servlet name.

  Specified by:
    `getServlet` in interface `javax.servlet.ServletContext`
  Parameters:
    `name` - Name of the requested servlet
  Throws:
    `javax.servlet.ServletException`

### getServletContextName

    public java.lang.String getServletContextName()

  Return the name of this servlet context.

  Specified by:
    `getServletContextName` in interface `javax.servlet.ServletContext`
  Returns:
    The name of the web application or null if no name has been declared in the deployment descriptor.

### getServletNames

    public java.util.Enumeration getServletNames()

  Deprecated. This method has been deprecated with no replacement

  Return an empty enumeration of servlet names.

  Specified by:
    `getServletNames` in interface `javax.servlet.ServletContext`

### getServlets

    public java.util.Enumeration getServlets()

  Deprecated. This method has been deprecated with no replacement

  Return an empty enumeration of servlets.

  Specified by:
    `getServlets` in interface `javax.servlet.ServletContext`

### log

    public void log(java.lang.String message)

  Log the specified message.

  Specified by:
    `log` in interface `javax.servlet.ServletContext`
  Parameters:
    `message` - The message to be logged

### log

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

  Deprecated. Use log(String,Throwable) instead

  Log the specified message and exception.

  Specified by:
    `log` in interface `javax.servlet.ServletContext`
  Parameters:
    `exception` - The exception to be logged
    `message` - The message to be logged

### log

    public void log(java.lang.String message,
                    java.lang.Throwable exception)

  Log the specified message and exception.

  Specified by:
    `log` in interface `javax.servlet.ServletContext`
  Parameters:
    `message` - The message to be logged
    `exception` - The exception to be logged

### removeAttribute

    public void removeAttribute(java.lang.String name)

  Remove the specified context attribute.

  Specified by:
    `removeAttribute` in interface `javax.servlet.ServletContext`
  Parameters:
    `name` - Name of the attribute to remove

### setAttribute

    public void setAttribute(java.lang.String name,
                             java.lang.Object value)

  Set or replace the specified context attribute.

  Specified by:
    `setAttribute` in interface `javax.servlet.ServletContext`
  Parameters:
    `name` - Name of the context attribute to set
    `value` - Corresponding attribute value

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Copyright © 2000-2008 Apache Software Foundation. All Rights Reserved.