Class HttpController

java.lang.Object
io.github.jirkasa.servletrouter.Controller<javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse>
io.github.jirkasa.servletrouter.HttpController

public abstract class HttpController extends Controller<javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse>
Implementation of Controller that uses HTTP protocol (HttpServletRequest and HttpServletResponse).
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    protected boolean
    Determines whether handlers chain should continue or not when method is not implemented in subclass.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected void
    When called, the handlers chain will continue (another handlers/controllers that match request path will be called).
    boolean
    handle(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
    Handles request.
    protected void
    handleDelete(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
    Handles DELETE requests.
    protected void
    handleGet(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
    Handles GET requests.
    protected void
    handleHead(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
    Handles HEAD requests.
    protected void
    handleOptions(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
    Handles OPTIONS requests.
    protected void
    handlePatch(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
    Handles PATCH requests.
    protected void
    handlePost(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
    Handles POST requests.
    protected void
    handlePut(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
    Handles PUT requests.
    protected void
    handleTrace(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response)
    Handles TRACE requests.

    Methods inherited from class io.github.jirkasa.servletrouter.Controller

    forwardTo, getPathParam

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • skipUnimplementedMethods

      protected boolean skipUnimplementedMethods
      Determines whether handlers chain should continue or not when method is not implemented in subclass.
  • Constructor Details

    • HttpController

      public HttpController()
  • Method Details

    • handle

      public boolean handle(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws Exception
      Handles request. For controller that handles 404 page, this method should be overwritten.
      Specified by:
      handle in class Controller<javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse>
      Parameters:
      request - Request to be handled.
      response - Response to be handled.
      Returns:
      Determines whether handlers chain should continue or not.
      Throws:
      Exception
    • handleGet

      protected void handleGet(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws Exception
      Handles GET requests.
      Parameters:
      request - Request to be handled.
      response - Response to be handled.
      Throws:
      Exception
    • handlePost

      protected void handlePost(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws Exception
      Handles POST requests.
      Parameters:
      request - Request to be handled.
      response - Response to be handled.
      Throws:
      Exception
    • handlePut

      protected void handlePut(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws Exception
      Handles PUT requests.
      Parameters:
      request - Request to be handled.
      response - Response to be handled.
      Throws:
      Exception
    • handlePatch

      protected void handlePatch(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws Exception
      Handles PATCH requests.
      Parameters:
      request - Request to be handled.
      response - Response to be handled.
      Throws:
      Exception
    • handleDelete

      protected void handleDelete(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws Exception
      Handles DELETE requests.
      Parameters:
      request - Request to be handled.
      response - Response to be handled.
      Throws:
      Exception
    • handleHead

      protected void handleHead(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws Exception
      Handles HEAD requests.
      Parameters:
      request - Request to be handled.
      response - Response to be handled.
      Throws:
      Exception
    • handleOptions

      protected void handleOptions(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws Exception
      Handles OPTIONS requests. In the vast majority of cases, it should not be overwritten in subclasses.
      Parameters:
      request - Request to be handled.
      response - Response to be handled.
      Throws:
      Exception
    • handleTrace

      protected void handleTrace(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws Exception
      Handles TRACE requests. In the vast majority of cases, it should not be overwritten in subclasses.
      Parameters:
      request - Request to be handled.
      response - Response to be handled.
      Throws:
      Exception
    • continueHandlersChain

      protected void continueHandlersChain()
      When called, the handlers chain will continue (another handlers/controllers that match request path will be called).