Class FrameworkServlet

java.lang.Object
jakarta.servlet.GenericServlet
jakarta.servlet.http.HttpServlet
com.bobocode.bring.web.servlet.FrameworkServlet
All Implemented Interfaces:
jakarta.servlet.Servlet, jakarta.servlet.ServletConfig, Serializable
Direct Known Subclasses:
DispatcherServlet

public abstract class FrameworkServlet extends jakarta.servlet.http.HttpServlet
The FrameworkServlet is an abstract class that extends HttpServlet and provides a base implementation for handling HTTP requests in a framework. Subclasses must implement the processRequest method to handle specific request processing.

This servlet initializes and processes various HTTP methods (GET, HEAD, POST, PUT, DELETE, OPTIONS, TRACE). Each method is delegated to the common processRequest method.

Since:
1.0
Author:
Blyzhnytsia Team
See Also:
  • Field Summary

    Fields inherited from class jakarta.servlet.http.HttpServlet

    LEGACY_DO_HEAD
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected void
    doDelete(jakarta.servlet.http.HttpServletRequest req, jakarta.servlet.http.HttpServletResponse resp)
    Handles HTTP DELETE requests by delegating to the common processRequest method.
    protected void
    doGet(jakarta.servlet.http.HttpServletRequest req, jakarta.servlet.http.HttpServletResponse resp)
    Handles HTTP GET requests by delegating to the common processRequest method.
    protected void
    doHead(jakarta.servlet.http.HttpServletRequest req, jakarta.servlet.http.HttpServletResponse resp)
    Handles HTTP HEAD requests by delegating to the common processRequest method.
    protected void
    doOptions(jakarta.servlet.http.HttpServletRequest req, jakarta.servlet.http.HttpServletResponse resp)
    Handles HTTP OPTIONS requests by delegating to the common processRequest method.
    protected void
    doPost(jakarta.servlet.http.HttpServletRequest req, jakarta.servlet.http.HttpServletResponse resp)
    Handles HTTP POST requests by delegating to the common processRequest method.
    protected void
    doPut(jakarta.servlet.http.HttpServletRequest req, jakarta.servlet.http.HttpServletResponse resp)
    Handles HTTP PUT requests by delegating to the common processRequest method.
    protected void
    doTrace(jakarta.servlet.http.HttpServletRequest req, jakarta.servlet.http.HttpServletResponse resp)
    Handles HTTP TRACE requests by delegating to the common processRequest method.
    void
    init(jakarta.servlet.ServletConfig config)
    Initializes the servlet with the provided configuration.
    abstract void
    processRequest(jakarta.servlet.http.HttpServletRequest req, jakarta.servlet.http.HttpServletResponse resp)
    Processes the HTTP request.

    Methods inherited from class jakarta.servlet.http.HttpServlet

    getLastModified, 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
  • Constructor Details

    • FrameworkServlet

      public FrameworkServlet()
  • Method Details

    • init

      public void init(jakarta.servlet.ServletConfig config)
      Initializes the servlet with the provided configuration.
      Specified by:
      init in interface jakarta.servlet.Servlet
      Overrides:
      init in class jakarta.servlet.http.HttpServlet
      Parameters:
      config - The servlet configuration.
    • doGet

      protected void doGet(jakarta.servlet.http.HttpServletRequest req, jakarta.servlet.http.HttpServletResponse resp)
      Handles HTTP GET requests by delegating to the common processRequest method.
      Overrides:
      doGet in class jakarta.servlet.http.HttpServlet
    • doHead

      protected void doHead(jakarta.servlet.http.HttpServletRequest req, jakarta.servlet.http.HttpServletResponse resp)
      Handles HTTP HEAD requests by delegating to the common processRequest method.
      Overrides:
      doHead in class jakarta.servlet.http.HttpServlet
    • doPost

      protected void doPost(jakarta.servlet.http.HttpServletRequest req, jakarta.servlet.http.HttpServletResponse resp)
      Handles HTTP POST requests by delegating to the common processRequest method.
      Overrides:
      doPost in class jakarta.servlet.http.HttpServlet
    • doPut

      protected void doPut(jakarta.servlet.http.HttpServletRequest req, jakarta.servlet.http.HttpServletResponse resp)
      Handles HTTP PUT requests by delegating to the common processRequest method.
      Overrides:
      doPut in class jakarta.servlet.http.HttpServlet
    • doDelete

      protected void doDelete(jakarta.servlet.http.HttpServletRequest req, jakarta.servlet.http.HttpServletResponse resp)
      Handles HTTP DELETE requests by delegating to the common processRequest method.
      Overrides:
      doDelete in class jakarta.servlet.http.HttpServlet
    • doOptions

      protected void doOptions(jakarta.servlet.http.HttpServletRequest req, jakarta.servlet.http.HttpServletResponse resp)
      Handles HTTP OPTIONS requests by delegating to the common processRequest method.
      Overrides:
      doOptions in class jakarta.servlet.http.HttpServlet
    • doTrace

      protected void doTrace(jakarta.servlet.http.HttpServletRequest req, jakarta.servlet.http.HttpServletResponse resp)
      Handles HTTP TRACE requests by delegating to the common processRequest method.
      Overrides:
      doTrace in class jakarta.servlet.http.HttpServlet
    • processRequest

      public abstract void processRequest(jakarta.servlet.http.HttpServletRequest req, jakarta.servlet.http.HttpServletResponse resp)
      Processes the HTTP request. Subclasses must implement this method to handle specific request processing.
      Parameters:
      req - The HTTP request.
      resp - The HTTP response.