HttpDispatcher

public class HttpDispatcher extends HttpServlet

HttpDispatcher is an HttpServlet which dispatches Http request to the Http request listeners registered in its Http dispatcher context.

Author:Hugo Y. K. Lam

See also: HttpDispatcherContext

Fields

CONFIG_KEY

public static final String CONFIG_KEY

The request attribute key of the servlet config.

Methods

destroy

public void destroy()

Destroys the servlet.

doDelete

protected void doDelete(HttpServletRequest request, HttpServletResponse response)

Handles the HTTP POST method.

Parameters:
  • request – the servlet request.
  • response – the servlet response.

doGet

protected void doGet(HttpServletRequest request, HttpServletResponse response)

Handles the HTTP GET method.

Parameters:
  • request – the servlet request.
  • response – the servlet response.

doPost

protected void doPost(HttpServletRequest request, HttpServletResponse response)

Handles the HTTP POST method.

Parameters:
  • request – the servlet request.
  • response – the servlet response.

fireRequestAcceptedEvent

protected boolean fireRequestAcceptedEvent(HttpRequestEvent event)

Invoked before a request is processed by the listener registered at the request context path which is relative to this servlet’s context path.

Parameters:
  • event – the HTTP request event.
Returns:

true if the request should be accepted and processed by the registered listener.

fireRequestProcessedEvent

protected void fireRequestProcessedEvent(HttpRequestEvent event)

Invoked when a request has been processed by the listener registered at the request context path which is relative to this servlet’s context path.

Parameters:
  • event – the HTTP request event.

getServletInfo

public String getServletInfo()

Gets a short description of this servlet.

Returns:a short description of this servlet.

init

public void init(ServletConfig config)

Initializes the servlet.

Parameters:
  • config – the ServletConfig.
Throws:
  • ServletException – if error occurred in initialization.

processRequest

protected void processRequest(HttpServletRequest request, HttpServletResponse response)

Processes requests for both HTTP GET and POST methods.

Parameters:
  • request – servlet request.
  • response – servlet response.