: Class ServletHolder

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

## com.mortbay.HTTP.Handler
Class ServletHolder

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

public class ServletHolder
extends java.lang.Object
implements javax.servlet.ServletConfig

Servlet Holder Holds the name, params and some state of a javax.servlet.GenericServlet instance. It implements the ServletConfig interface. This class will organise the loading of the servlet when needed or requested.

#### Note

By default, responses will only use chunking if requested by the by setting the transfer encoding header. However, if the chunkByDefault is set, then chunking is used if no content length is set.

Version:
  $Id: ServletHolder.java,v 2.15 2000/03/31 22:31:35 gregw Exp $
Author:
  Greg Wilkins
See Also:
  `ServletHandler`

Constructor Summary
`ServletHolder(java.lang.String name, javax.servlet.GenericServlet sl)` Construct a Servlet Holder from an already instantiated and initialized servlet.
`ServletHolder(java.lang.String name, java.lang.String className)` Construct a Servlet property mostly from the servers config file.
`ServletHolder(java.lang.String name, java.lang.String className, java.util.Hashtable initParams)` Construct a Servlet property mostly from the servers config file.
`ServletHolder(java.lang.String name, java.lang.String className, java.util.Hashtable initParams, boolean initialize)` Construct a Servlet property mostly from the servers config file.
`ServletHolder(java.lang.String servletLoaderName, java.lang.String name, java.lang.String className, java.lang.String classPath, java.util.Hashtable initParams)` Construct a Servlet property mostly from the servers config file.

Method Summary
`void` | `destroy()` Destroy.
`int` | `getActiveRequests()`
`boolean` | `getChunkByDefault()` Set chunkByDefault
`java.lang.String` | `getInitParameter(java.lang.String param)` Gets an initialization parameter of the servlet.
`java.util.Enumeration` | `getInitParameterNames()` Returns an enumeration of strings representing the initialization parameters for this servlet.
`int` | `getNumRequests()`
`javax.servlet.GenericServlet` | `getServlet()` Get the servlet.
`javax.servlet.ServletContext` | `getServletContext()` Return server as the ServletContext.
`void` | `reload()` Reload the servlet.
`void` | `service(HttpRequest request, HttpResponse response)` Service a request with this servlet.
`void` | `setAutoReload(boolean autoReload)` Set autoReload.
`void` | `setChunkByDefault(boolean chunk)` Set chunkByDefault
`void` | `setInitialize(boolean initialize)` Set Initialize flag.
`void` | `setServer(HttpServer server)` Set server.
`java.lang.String` | `toString()` Get the name of the Servlet

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

Constructor Detail

### ServletHolder

    public ServletHolder(java.lang.String name,
                         java.lang.String className)
                  throws java.lang.ClassNotFoundException

  Construct a Servlet property mostly from the servers config file.

### ServletHolder

    public ServletHolder(java.lang.String name,
                         java.lang.String className,
                         java.util.Hashtable initParams)
                  throws java.lang.ClassNotFoundException

  Construct a Servlet property mostly from the servers config file.
  Parameters:
    `name` - Servlet name
    `className` - Servlet class name (fully qualified)
    `initParams` - Hashtable of parameters

### ServletHolder

    public ServletHolder(java.lang.String servletLoaderName,
                         java.lang.String name,
                         java.lang.String className,
                         java.lang.String classPath,
                         java.util.Hashtable initParams)
                  throws java.lang.ClassNotFoundException

  Construct a Servlet property mostly from the servers config file.
  Parameters:
    `servletLoaderName` - ServletLoader class name (or null)
    `name` - Servlet name
    `className` - Servlet class name (fully qualified)
    `classPath` - Servlet class path of directories and jars
    `initParams` - Hashtable of parameters

### ServletHolder

    public ServletHolder(java.lang.String name,
                         java.lang.String className,
                         java.util.Hashtable initParams,
                         boolean initialize)
                  throws java.lang.ClassNotFoundException

  Construct a Servlet property mostly from the servers config file.
  Parameters:
    `name` - Servlet name
    `className` - Servlet class name (fully qualified)
    `initParams` - Hashtable of parameters
    `initialize` - Set Initialize

### ServletHolder

    public ServletHolder(java.lang.String name,
                         javax.servlet.GenericServlet sl)

  Construct a Servlet Holder from an already instantiated and initialized servlet. This is useful for back-end applications that need to customize/initialize on their own a servlet front-end.
  Parameters:
    `name` - Servlet name
    `sl` - The servlet object

Method Detail

### reload

    public void reload()

  Reload the servlet. Reload the servlet and all associated classes by disposing of the class loader instance.

### setInitialize

    public void setInitialize(boolean initialize)

  Set Initialize flag. If set to true, the servlet is initialized when setServer is called.
  Parameters:
    `initialize` - Initialize at load time if true.

### setServer

    public void setServer(HttpServer server)
                   throws javax.servlet.ServletException,
                          java.lang.ClassNotFoundException,
                          java.lang.IllegalAccessException,
                          java.lang.InstantiationException

  Set server. Called during initialization by ServletHandler

### destroy

    public void destroy()

  Destroy.

### getServlet

    public javax.servlet.GenericServlet getServlet()
                                            throws javax.servlet.UnavailableException

  Get the servlet. The state of the servlet is unknown, specially if using SingleThreadModel
  Returns:
    The servlet

### setChunkByDefault

    public void setChunkByDefault(boolean chunk)

  Set chunkByDefault
  Parameters:
    `chunk` - If True, servlets without content lengths that have not explicitly requested a closing connection, will use HTTP/1.1 chunking if possible.

### setAutoReload

    public void setAutoReload(boolean autoReload)

  Set autoReload.
  Parameters:
    `autoReload` - If true, an expensive check is made on each servlet requests to see if the servlet has been modified and should be reloaded.

### getChunkByDefault

    public boolean getChunkByDefault()

  Set chunkByDefault
  Parameters:
    `chunk` - If True, servlets without content lengths that have not explicitly requested a closing connection, will use HTTP/1.1 chunking if possible.

### getServletContext

    public javax.servlet.ServletContext getServletContext()

  Return server as the ServletContext.
  Specified by:
    getServletContext in interface javax.servlet.ServletConfig
  Tags copied from interface: javax.servlet.ServletConfig
  Returns:
    a `ServletContext` object, which gives the servlet information about how to interact with the server
  See Also:
    `ServletContext`

### getInitParameter

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

  Gets an initialization parameter of the servlet.
  Specified by:
    getInitParameter in interface javax.servlet.ServletConfig
  Parameters:
    `name` - the parameter name

### getInitParameterNames

    public java.util.Enumeration getInitParameterNames()

  Returns an enumeration of strings representing the initialization parameters for this servlet.
  Specified by:
    getInitParameterNames in interface javax.servlet.ServletConfig
  Tags copied from interface: javax.servlet.ServletConfig
  Returns:
    an `Enumeration` of `String` objects containing the names of the servlet's initialization parameters

### service

    public void service(HttpRequest request,
                        HttpResponse response)
                 throws javax.servlet.ServletException,
                        javax.servlet.UnavailableException,
                        java.io.IOException

  Service a request with this servlet.
  Parameters:
    `request` - The request
    `response` - The response
  Throws:
    javax.servlet.ServletException - ServletException
    javax.servlet.UnavailableException - UnavailableException
    java.io.IOException - IOException

### getNumRequests

    public int getNumRequests()

### getActiveRequests

    public int getActiveRequests()

### toString

    public java.lang.String toString()

  Get the name of the Servlet
  Overrides:
    toString in class java.lang.Object
  Returns:
    Servlet name

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