Class BaseServlet

java.lang.Object
jakarta.servlet.GenericServlet
jakarta.servlet.http.HttpServlet
com.avoka.fc.core.servlet.BaseServlet
All Implemented Interfaces:
jakarta.servlet.Servlet, jakarta.servlet.ServletConfig, Serializable
Direct Known Subclasses:
EmailVerificationServlet, FormDynamicDataServlet, HostedPaymentServlet, ReceiptCommandServlet, RenderServlet, SubmissionServlet

public abstract class BaseServlet extends jakarta.servlet.http.HttpServlet
Provides a base servlet for other servlet to extend.
See Also:
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
    The invalid request page
    static final String
    The offline page

    Fields inherited from class jakarta.servlet.http.HttpServlet

    LEGACY_DO_HEAD
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected final void
    doGet(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response)
     
    protected final void
    doPost(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response)
     
    protected abstract void
    executeRequest(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response)
    Abstract execute request method subclasses must implement.
    protected org.apache.cayenne.access.DataContext
     
     
    protected abstract ErrorLogService
     
    protected String
    getErrorPagePath(jakarta.servlet.http.HttpServletRequest request)
     
    protected org.slf4j.Logger
    Return the service log.
    protected Map<String,Object>
    getMultiPartRequestMap(jakarta.servlet.http.HttpServletRequest request)
     
    protected String
    getParameterString(jakarta.servlet.http.HttpServletRequest request, String name)
    This will return "" if there is a null value.
    protected String
    getParameterString(jakarta.servlet.http.HttpServletRequest request, String name, String defaultValue)
     
    protected String
    getParameterStringTrim(jakarta.servlet.http.HttpServletRequest request, String name)
    returns the string parameter, stripping out anything from the first '#' character e.g.
    protected jakarta.servlet.http.HttpServletRequest
     
    Return an ordered map of request parameters from the request.
    protected jakarta.servlet.http.HttpServletResponse
     
    protected void
    handleException(Throwable error, String userName, jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response)
     
    protected void
    handleRequest(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response)
     
    protected boolean
    hasPermission(jakarta.servlet.http.HttpServletRequest request, String permission)
    Return true if user is logged in and has permission, false otherwise.
    protected boolean
    hasPermission(jakarta.servlet.http.HttpServletRequest request, String permission1, String permission2)
    Return true if user is logged in and has one of the given permissions, false otherwise.
    protected boolean
    hasPermission(jakarta.servlet.http.HttpServletRequest request, String permission1, String permission2, String permission3)
    Return true if user is logged in and has one of the given permissions, false otherwise.
    protected void
    listServletInfo(jakarta.servlet.http.HttpServletRequest request)
    List all the servlet request information when in application is in debug mode.
    protected void
    sendRedirect(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, String path)
     
    protected void
    sendResponseError(int status)
    Set the response error status code.

    Methods inherited from class jakarta.servlet.http.HttpServlet

    doDelete, doHead, doOptions, doPut, doTrace, getLastModified, init, service, service

    Methods inherited from class jakarta.servlet.GenericServlet

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

    Methods inherited from class java.lang.Object

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

  • Constructor Details

    • BaseServlet

      public BaseServlet()
  • Method Details

    • executeRequest

      protected abstract void executeRequest(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response) throws IOException
      Abstract execute request method subclasses must implement. Subclasses should not override the doGet or doPost methods.
      Parameters:
      request - the servlet request
      response - the servlet response
      Throws:
      InvalidParameterException - if an invalid request occurs
      IOException - if an invalid request occurs
    • getErrorLogService

      protected abstract ErrorLogService getErrorLogService()
      Returns:
      the servlet error log service
      Since:
      4.3.4
    • doGet

      protected final void doGet(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response) throws jakarta.servlet.ServletException, IOException
      Overrides:
      doGet in class jakarta.servlet.http.HttpServlet
      Throws:
      jakarta.servlet.ServletException
      IOException
    • doPost

      protected final void doPost(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response) throws jakarta.servlet.ServletException, IOException
      Overrides:
      doPost in class jakarta.servlet.http.HttpServlet
      Throws:
      jakarta.servlet.ServletException
      IOException
    • hasPermission

      protected boolean hasPermission(jakarta.servlet.http.HttpServletRequest request, String permission)
      Return true if user is logged in and has permission, false otherwise.
      Since:
      22.4.0
    • hasPermission

      protected boolean hasPermission(jakarta.servlet.http.HttpServletRequest request, String permission1, String permission2)
      Return true if user is logged in and has one of the given permissions, false otherwise.
      Since:
      22.4.0
    • hasPermission

      protected boolean hasPermission(jakarta.servlet.http.HttpServletRequest request, String permission1, String permission2, String permission3)
      Return true if user is logged in and has one of the given permissions, false otherwise.
      Since:
      22.4.0
    • handleRequest

      protected void handleRequest(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response) throws jakarta.servlet.ServletException, IOException
      Throws:
      jakarta.servlet.ServletException
      IOException
    • handleException

      protected void handleException(Throwable error, String userName, jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response)
    • getErrorPagePath

      protected String getErrorPagePath(jakarta.servlet.http.HttpServletRequest request)
    • sendResponseError

      protected void sendResponseError(int status)
      Set the response error status code.
      Parameters:
      status - the error status
      Since:
      4.1.0
    • getLogger

      protected org.slf4j.Logger getLogger()
      Return the service log.
    • getDataContext

      protected org.apache.cayenne.access.DataContext getDataContext()
    • getDeploymentPropertyDao

      protected DeploymentPropertyDao getDeploymentPropertyDao()
    • getRequest

      protected jakarta.servlet.http.HttpServletRequest getRequest()
    • getResponse

      protected jakarta.servlet.http.HttpServletResponse getResponse()
    • getParameterString

      protected String getParameterString(jakarta.servlet.http.HttpServletRequest request, String name)
      This will return "" if there is a null value.
    • getParameterString

      protected String getParameterString(jakarta.servlet.http.HttpServletRequest request, String name, String defaultValue)
    • getParameterStringTrim

      protected String getParameterStringTrim(jakarta.servlet.http.HttpServletRequest request, String name)
      returns the string parameter, stripping out anything from the first '#' character e.g. submitKey=12345#zoom=100 becomes 12345 rather than 12345#zoom=100
    • getRequestParameters

      public Map getRequestParameters()
      Return an ordered map of request parameters from the request.
      Returns:
      the ordered map of request parameters
    • listServletInfo

      protected void listServletInfo(jakarta.servlet.http.HttpServletRequest request)
      List all the servlet request information when in application is in debug mode.
    • sendRedirect

      protected void sendRedirect(jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response, String path) throws ApplicationException
      Throws:
      ApplicationException
    • getMultiPartRequestMap

      protected Map<String,Object> getMultiPartRequestMap(jakarta.servlet.http.HttpServletRequest request) throws org.apache.commons.fileupload.FileUploadException
      Throws:
      org.apache.commons.fileupload.FileUploadException