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

## org.apache.tomcat.facade
Class ServletHandler

    java.lang.Object
      org.apache.tomcat.core.Handler
          org.apache.tomcat.facade.ServletHandler

public final class ServletHandler
extends Handler

Handler for servlets. It'll implement all servlet-specific requirements ( init, Unavailable exception, etc). It is also used for Jsps ( since a Jsp is a servlet ), but requires the Jsp interceptor to make sure that indeed a Jsp is a servlet ( and set the class name ). The old Jsp hack is no longer supported ( i.e. declaring a servlet with the name jsp, mapping *.jsp -> jsp will work as required by the servlet spec - no special hook is provided for initialization ). Note that JspServlet doesn't work without special cases in ServletWrapper.

Author:
  James Duncan Davidson [duncan@eng.sun.com], Jason Hunter [jch@eng.sun.com], James Todd [gonzo@eng.sun.com], Harish Prabandham, Costin Manolache

Field Summary
`protected Context` | `context`
`protected javax.servlet.Servlet` | `servlet`
`protected java.lang.Class` | `servletClass`
`static int` | `STATE_DELAYED_INIT` If init() fails or preInit() detects the handler is still unavailable.
`static int` | `STATE_READY` The handler has been succesfully initialized and is ready to serve requests.

Fields inherited from class org.apache.tomcat.core.Handler
`contextM, debug, errorException, logger, module, name, next, prev, state, STATE_ADDED, STATE_DISABLED, STATE_NEW`

Constructor Summary
`ServletHandler()`

Method Summary
`java.lang.String[]` | `_getDepends()` The handler may return a set of classes it depends on
`void` | `destroy()` Destroy a handler, and notify all the interested interceptors
`protected void` | `doDestroy()`
`protected void` | `doInit()`
`protected void` | `doService(Request req, Response res)`
`protected void` | `doSTMService(javax.servlet.http.HttpServletRequest reqF, javax.servlet.http.HttpServletResponse resF)`
`Context` | `getContext()` Return the context associated with the handler
`javax.servlet.Servlet` | `getServlet()`
`java.lang.String` | `getServletClassName()`
`ServletInfo` | `getServletInfo()`
`protected void` | `handleInitError(Request req, Response res, java.lang.Throwable t)`
`protected void` | `handleServiceError(Request req, Response res, java.lang.Throwable t)`
`void` | `init()` Call the init method, and notify all interested listeners.
`protected void` | `preInit()`
`void` | `reload()` Reload notification.
`void` | `service(Request req, Response res)` Call the service method, and notify all listeners
`void` | `setContext(Context context)`
`void` | `setServletClassName(java.lang.String servletClassName)`
`void` | `setServletInfo(ServletInfo sw)`
`void` | `setSTMPoolSize(int size)`
`void` | `setUseSTMPool(boolean useP)`
`java.lang.String` | `toString()`

Methods inherited from class org.apache.tomcat.core.Handler
`getErrorException, getModule, getName, getNext, getNote, getNote, getPrevious, getState, invoke, log, log, setContextManager, setDebug, setErrorException, setModule, setName, setNext, setNote, setNote, setPrevious, setState`

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

Field Detail

### STATE_DELAYED_INIT

    public static final int STATE_DELAYED_INIT

  If init() fails or preInit() detects the handler is still unavailable.

  See Also:
    Constant Field Values

### STATE_READY

    public static final int STATE_READY

  The handler has been succesfully initialized and is ready to serve requests. If the handler is not in this state a 500 error should be reported. ( customize - may be 404 ) To ADDED by calling destroy() To DISABLED if permanent UnavailableException in service() FROM ADDED by calling init() Note: Once this state is reached, only UnavailableExceptions are stored in errorException.

  See Also:
    Constant Field Values

### servletClass

    protected java.lang.Class servletClass

### servlet

    protected javax.servlet.Servlet servlet

### context

    protected Context context

Constructor Detail

### ServletHandler

    public ServletHandler()

Method Detail

### toString

    public java.lang.String toString()

  Overrides:
    `toString` in class `Handler`

### setServletInfo

    public void setServletInfo(ServletInfo sw)

### setUseSTMPool

    public void setUseSTMPool(boolean useP)

### setSTMPoolSize

    public void setSTMPoolSize(int size)

### getServletInfo

    public ServletInfo getServletInfo()

### setContext

    public void setContext(Context context)

### getContext

    public Context getContext()

  Return the context associated with the handler

### setServletClassName

    public void setServletClassName(java.lang.String servletClassName)

### getServletClassName

    public java.lang.String getServletClassName()

### destroy

    public final void destroy()

  Destroy a handler, and notify all the interested interceptors

  Overrides:
    `destroy` in class `Handler`

### init

    public final void init()

  Call the init method, and notify all interested listeners. This is a final method to insure consistent behavior on errors. It also saves handlers from dealing with synchronization issues.

  Overrides:
    `init` in class `Handler`

### reload

    public void reload()

  Description copied from class: `Handler`
  Reload notification. This hook is called whenever the application ( this handler ) is reloaded

  Overrides:
    `reload` in class `Handler`

### getServlet

    public javax.servlet.Servlet getServlet()
                                     throws java.lang.ClassNotFoundException,
                                            java.lang.InstantiationException,
                                            java.lang.IllegalAccessException

  Throws:
    `java.lang.ClassNotFoundException`
    `java.lang.InstantiationException`
    `java.lang.IllegalAccessException`

### doDestroy

    protected void doDestroy()
                      throws TomcatException

  Throws:
    `TomcatException`

### preInit

    protected void preInit()
                    throws java.lang.Exception

  Throws:
    `java.lang.Exception`

### doInit

    protected void doInit()
                   throws java.lang.Exception

  Throws:
    `java.lang.Exception`

### service

    public void service(Request req,
                        Response res)
                 throws java.lang.Exception

  Description copied from class: `Handler`
  Call the service method, and notify all listeners

  Overrides:
    `service` in class `Handler`
  Throws:
    `java.lang.Exception` - if an error happens during handling of the request. Common errors are:
    - IOException if an input/output error occurs and we are processing an included servlet (otherwise it is swallowed and handled by the top level error handler mechanism)
    - ServletException if a servlet throws an exception and we are processing an included servlet (otherwise it is swallowed and handled by the top level error handler mechanism)
    Tomcat should be able to handle and log any other exception ( including runtime exceptions )

### doSTMService

    protected void doSTMService(javax.servlet.http.HttpServletRequest reqF,
                                javax.servlet.http.HttpServletResponse resF)
                         throws java.lang.Exception

  Throws:
    `java.lang.Exception`

### doService

    protected void doService(Request req,
                             Response res)
                      throws java.lang.Exception

  Overrides:
    `doService` in class `Handler`
  Throws:
    `java.lang.Exception`

### handleInitError

    protected void handleInitError(Request req,
                                   Response res,
                                   java.lang.Throwable t)

### handleServiceError

    protected void handleServiceError(Request req,
                                      Response res,
                                      java.lang.Throwable t)
                               throws java.lang.Exception

  Overrides:
    `handleServiceError` in class `Handler`
  Throws:
    `java.lang.Exception`

### _getDepends

    public java.lang.String[] _getDepends()

  The handler may return a set of classes it depends on

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

Copyright © 2001 Apache Software Foundation. All Rights Reserved.