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

## org.apache.jserv
Class JServContext

    java.lang.Object
      |
      +--org.apache.jserv.JServContext

class JServContext
extends java.lang.Object
implements javax.servlet.ServletConfig, javax.servlet.ServletContext, JServSendError, JServLogChannels

This class implements the parts of the servlet that are longer-lived than a single request, ServletConfig and ServletContext.

There is one `JServContext` object for each servlet, and they are managed by `JServServletManager`.

Version:
  $Revision: 1.13 $ $Date: 1999/04/26 00:33:59 $

Field Summary
`(package private) java.lang.String` | `aliasName`
`private java.util.Properties` | `initargs`
`(package private) Lock` | `lock`
`(package private) javax.servlet.Servlet` | `servlet`
`private JServServletManager` | `servletMgr`

Constructor Summary
`JServContext(javax.servlet.Servlet servlet, JServServletManager manager, java.util.Properties initargs, java.lang.String aliasName)`

Method Summary
`java.lang.Object` | `getAttribute(java.lang.String name)` Returns the value of the named attribute of the network service, or null if the attribute does not exist.
`java.lang.String` | `getInitParameter(java.lang.String name)` Returns a string containing the value of the named initialization parameter of the servlet, or null if the parameter does not exist.
`java.util.Enumeration` | `getInitParameterNames()` Returns the names of the servlet's initialization parameters as an enumeration of strings, or an empty enumeration if there are no initialization parameters.
`java.lang.String` | `getMimeType(java.lang.String f)` Returns the mime type of the specified file, or null if not known.
`java.lang.String` | `getRealPath(java.lang.String path)` Applies alias rules to the specified virtual path and returns the corresponding real path.
`java.lang.String` | `getServerInfo()` Returns the name and version of the network service under which the servlet is running.
`javax.servlet.Servlet` | `getServlet()`
`javax.servlet.Servlet` | `getServlet(java.lang.String name)` Returns the servlet of the specified name, or null if not found.
`javax.servlet.ServletContext` | `getServletContext()` Returns the context for the servlet.
`java.util.Enumeration` | `getServletNames()` Returns an enumeration of the Servlet object names in this server.
`java.util.Enumeration` | `getServlets()` Deprecated. Please use getServletNames in conjunction with getServlet
`void` | `log(java.lang.Exception ex, java.lang.String msg)` Write the stacktrace and the given message string to the servlet log file.
`void` | `log(java.lang.String msg)` Writes the given message string to the servlet log file.
`void` | `log(java.lang.String msg, java.lang.Throwable t)` Write the given message string and the stacktrace to the servlet log file.
`void` | `sendError(int sc, java.lang.String msg)`
`void` | `sendError(java.lang.Throwable ex)`

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

Field Detail

### servletMgr

    private JServServletManager servletMgr

### servlet

    javax.servlet.Servlet servlet

### initargs

    private java.util.Properties initargs

### lock

    Lock lock

### aliasName

    java.lang.String aliasName

Constructor Detail

### JServContext

    public JServContext(javax.servlet.Servlet servlet,
                        JServServletManager manager,
                        java.util.Properties initargs,
                        java.lang.String aliasName)

Method Detail

### getServletContext

    public javax.servlet.ServletContext getServletContext()

  Returns the context for the servlet.
  Specified by:
    getServletContext in interface javax.servlet.ServletConfig

### getInitParameter

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

  Returns a string containing the value of the named initialization parameter of the servlet, or null if the parameter does not exist. Init parameters have a single string value; it is the responsibility of the servlet writer to interpret the string.
  Specified by:
    getInitParameter in interface javax.servlet.ServletConfig
  Parameters:
    `name` - the name of the parameter whose value is requested.

### getInitParameterNames

    public java.util.Enumeration getInitParameterNames()

  Returns the names of the servlet's initialization parameters as an enumeration of strings, or an empty enumeration if there are no initialization parameters.
  Specified by:
    getInitParameterNames in interface javax.servlet.ServletConfig

### getServlet

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

  Returns the servlet of the specified name, or null if not found. When the servlet is returned it is initialized and ready to accept service requests.

  Note: This is a dangerous method to call for the following reasons.

  - When this method is called the state of the servlet may not be known, and this could cause problems with the server's servlet state machine.
  - It is a security risk to allow any servlet to be able to access the methods of another servlet.
  Specified by:
    getServlet in interface javax.servlet.ServletContext
  Parameters:
    `name` - the name of the desired servlet.

### getServlets

    public java.util.Enumeration getServlets()

  Deprecated. Please use getServletNames in conjunction with getServlet
  Returns an enumeration of the Servlet objects in this server. Only servlets that are accessible (i.e., from the same namespace) will be returned. The enumeration always includes the servlet itself.

  Note: This is a dangerous method to call for the following reasons.

  - When this method is called the state of the servlet may not be known, and this could cause problems with the server's servlet state machine.
  - It is a security risk to allow any servlet to be able to access the methods of another servlet.
  Specified by:
    getServlets in interface javax.servlet.ServletContext
  See Also:
    `getServletNames()`, `getServlet(java.lang.String)`

### getServletNames

    public java.util.Enumeration getServletNames()

  Returns an enumeration of the Servlet object names in this server. Only servlets that are accessible (i.e., from the same namespace) will be returned. The enumeration always includes the servlet itself.

  Note: This is a dangerous method to call for the following reasons.

  - When this method is called the state of the servlet may not be known, and this could cause problems with the server's servlet state machine.
  - It is a security risk to allow any servlet to be able to access the methods of another servlet.
  Specified by:
    getServletNames in interface javax.servlet.ServletContext

### log

    public void log(java.lang.String msg)

  Writes the given message string to the servlet log file. The name of the servlet log file is server specific; it is normally an event log.
  Specified by:
    log in interface javax.servlet.ServletContext
  Parameters:
    `msg` - the message to be written

### log

    public void log(java.lang.Exception ex,
                    java.lang.String msg)

  Write the stacktrace and the given message string to the servlet log file. The name of the servlet log file is server specific; it is normally an event log.
  Specified by:
    log in interface javax.servlet.ServletContext
  Parameters:
    `exception` - the exception to be written.
    `msg` - the message to be written

### log

    public void log(java.lang.String msg,
                    java.lang.Throwable t)

  Write the given message string and the stacktrace to the servlet log file. The name of the servlet log file is server specific; it is normally an event log.
  Parameters:
    `msg` - the message to be written
    `t` - the exception to be written.
  Since:
    JSDK 2.1

### getRealPath

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

  Applies alias rules to the specified virtual path and returns the corresponding real path. For example, in an HTTP servlet, this method would resolve the path against the HTTP service's docroot. Returns null if virtual paths are not supported, or if the translation could not be performed for any reason.
  Specified by:
    getRealPath in interface javax.servlet.ServletContext
  Parameters:
    `path` - the virtual path to be translated into a real path

### getMimeType

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

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

### getServerInfo

    public java.lang.String getServerInfo()

  Returns the name and version of the network service under which the servlet is running. For example, if the network service was an HTTP service, then this would be the same as the CGI variable SERVER_SOFTWARE.
  Specified by:
    getServerInfo in interface javax.servlet.ServletContext

### getAttribute

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

  Returns the value of the named attribute of the network service, or null if the attribute does not exist. This method allows access to additional information about the service, not already provided by the other methods in this interface. Attribute names should follow the same convention as package names. The package names java.* and javax.* are reserved for use by Javasoft, and com.sun.* is reserved for use by Sun Microsystems.
  Specified by:
    getAttribute in interface javax.servlet.ServletContext
  Parameters:
    `name` - the name of the attribute whose value is required
  Returns:
    the value of the attribute, or null if the attribute does not exist.

### sendError

    public void sendError(int sc,
                          java.lang.String msg)

  Specified by:
    sendError in interface JServSendError

### sendError

    public void sendError(java.lang.Throwable ex)

  Specified by:
    sendError in interface JServSendError

### getServlet

    public javax.servlet.Servlet getServlet()

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