com.google.web.bindery.requestfactory.server

## Class RequestFactoryServlet

- java.lang.Object
- - javax.servlet.GenericServlet
  - - javax.servlet.http.HttpServlet
    - - com.google.web.bindery.requestfactory.server.RequestFactoryServlet

- All Implemented Interfaces:
    java.io.Serializable, javax.servlet.Servlet, javax.servlet.ServletConfig

      public class RequestFactoryServlet
      extends javax.servlet.http.HttpServlet

  Handles GWT RequestFactory JSON requests.
  See Also:
    Serialized Form

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `RequestFactoryServlet()` Constructs a new `RequestFactoryServlet` with a `DefaultExceptionHandler`.
    `RequestFactoryServlet(ExceptionHandler exceptionHandler, ServiceLayerDecorator... serviceDecorators)` Use this constructor in subclasses to provide a custom `ExceptionHandler`.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected void` | `doPost(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)` Processes a POST to the server.
    `static javax.servlet.http.HttpServletRequest` | `getThreadLocalRequest()` Returns the thread-local `HttpServletRequest`.
    `static javax.servlet.http.HttpServletResponse` | `getThreadLocalResponse()` Returns the thread-local `HttpServletResponse`.
    `static javax.servlet.ServletContext` | `getThreadLocalServletContext()` Returns the thread-local `ServletContext`

    - ### Methods inherited from class javax.servlet.http.HttpServlet

      `doDelete, doGet, doHead, doOptions, doPut, doTrace, getLastModified, service, service`

    - ### Methods inherited from class javax.servlet.GenericServlet

      `destroy, getInitParameter, getInitParameterNames, getServletConfig, getServletContext, getServletInfo, getServletName, init, init, log, log`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### RequestFactoryServlet

          public RequestFactoryServlet()

      Constructs a new `RequestFactoryServlet` with a `DefaultExceptionHandler`.

    - #### RequestFactoryServlet

          public RequestFactoryServlet(ExceptionHandler exceptionHandler,
                               ServiceLayerDecorator... serviceDecorators)

      Use this constructor in subclasses to provide a custom `ExceptionHandler`.
      Parameters:
        `exceptionHandler` - an `ExceptionHandler` instance
        `serviceDecorators` - an array of ServiceLayerDecorators that change how the RequestFactory request processor interact with the domain objects

  - ### Method Detail

    - #### getThreadLocalRequest

          public static javax.servlet.http.HttpServletRequest getThreadLocalRequest()

      Returns the thread-local `HttpServletRequest`.
      Returns:
        an `HttpServletRequest` instance

    - #### getThreadLocalResponse

          public static javax.servlet.http.HttpServletResponse getThreadLocalResponse()

      Returns the thread-local `HttpServletResponse`.
      Returns:
        an `HttpServletResponse` instance

    - #### getThreadLocalServletContext

          public static javax.servlet.ServletContext getThreadLocalServletContext()

      Returns the thread-local `ServletContext`
      Returns:
        the `ServletContext` associated with this servlet

    - #### doPost

          protected void doPost(javax.servlet.http.HttpServletRequest request,
                    javax.servlet.http.HttpServletResponse response)
                         throws java.io.IOException,
                                javax.servlet.ServletException

      Processes a POST to the server.
      Overrides:
        `doPost` in class `javax.servlet.http.HttpServlet`
      Parameters:
        `request` - an `HttpServletRequest` instance
        `response` - an `HttpServletResponse` instance
      Throws:
        `java.io.IOException` - if an internal I/O error occurs
        `javax.servlet.ServletException` - if an error occurs in the servlet