Class FrontController

java.lang.Object
jakarta.servlet.GenericServlet
jakarta.servlet.http.HttpServlet
mg.emberframework.core.FrontController
All Implemented Interfaces:
jakarta.servlet.Servlet, jakarta.servlet.ServletConfig, Serializable

public class FrontController extends jakarta.servlet.http.HttpServlet
The central servlet for handling HTTP requests in the Ember Framework.

This class extends HttpServlet to process GET and POST requests, initialize the framework, and manage URL mappings, initialization parameters, and exceptions. It is annotated with @MultipartConfig to support file uploads.

Since:
1.0.0
Version:
1.0.0
Author:
Sandratra NIAINA
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
    doGet(jakarta.servlet.http.HttpServletRequest req, jakarta.servlet.http.HttpServletResponse resp)
    Handles HTTP GET requests.
    protected void
    doPost(jakarta.servlet.http.HttpServletRequest req, jakarta.servlet.http.HttpServletResponse resp)
    Handles HTTP POST requests.
    static String
    Gets the custom error page URL.
    Gets the exception encountered during processing.
    Gets the initialization parameters.
    Gets the request handler.
    Gets the URL mappings.
    void
    Initializes the servlet by setting up the request handler and framework configuration.
    static void
    setCustomErrorPage(String customErrorPage)
    Sets the custom error page URL.
    static void
    setException(Exception newException)
    Sets the exception encountered during processing.
    static void
    setInitParameter(InitParameter newInitParameter)
    Sets the initialization parameters.
    void
    Sets the request handler.
    static void
    Sets the URL mappings.

    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, log, log

    Methods inherited from class java.lang.Object

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

    • FrontController

      public FrontController()
  • Method Details

    • doGet

      protected void doGet(jakarta.servlet.http.HttpServletRequest req, jakarta.servlet.http.HttpServletResponse resp) throws jakarta.servlet.ServletException, IOException
      Handles HTTP GET requests.
      Overrides:
      doGet in class jakarta.servlet.http.HttpServlet
      Parameters:
      req - the HTTP request
      resp - the HTTP response
      Throws:
      jakarta.servlet.ServletException - if a servlet error occurs
      IOException - if an I/O error occurs
    • doPost

      protected void doPost(jakarta.servlet.http.HttpServletRequest req, jakarta.servlet.http.HttpServletResponse resp) throws jakarta.servlet.ServletException, IOException
      Handles HTTP POST requests.
      Overrides:
      doPost in class jakarta.servlet.http.HttpServlet
      Parameters:
      req - the HTTP request
      resp - the HTTP response
      Throws:
      jakarta.servlet.ServletException - if a servlet error occurs
      IOException - if an I/O error occurs
    • init

      public void init() throws jakarta.servlet.ServletException
      Initializes the servlet by setting up the request handler and framework configuration.
      Overrides:
      init in class jakarta.servlet.GenericServlet
      Throws:
      jakarta.servlet.ServletException - if an error occurs during initialization
    • getUrlMapping

      public Map<String,Mapping> getUrlMapping()
      Gets the URL mappings.
      Returns:
      the map of URL mappings
    • setUrlMapping

      public static void setUrlMapping(Map<String,Mapping> urlMapping)
      Sets the URL mappings.
      Parameters:
      urlMapping - the map of URL mappings to set
    • getException

      public Exception getException()
      Gets the exception encountered during processing.
      Returns:
      the exception, or null if none
    • setException

      public static void setException(Exception newException)
      Sets the exception encountered during processing.
      Parameters:
      newException - the exception to set
    • getInitParameter

      public InitParameter getInitParameter()
      Gets the initialization parameters.
      Returns:
      the initialization parameters
    • setInitParameter

      public static void setInitParameter(InitParameter newInitParameter)
      Sets the initialization parameters.
      Parameters:
      newInitParameter - the initialization parameters to set
    • getRequestHandler

      public RequestHandler getRequestHandler()
      Gets the request handler.
      Returns:
      the request handler
    • setRequestHandler

      public void setRequestHandler(RequestHandler requestHandler)
      Sets the request handler.
      Parameters:
      requestHandler - the request handler to set
    • getCustomErrorPage

      public static String getCustomErrorPage()
      Gets the custom error page URL.
      Returns:
      the custom error page URL, or null if not set
    • setCustomErrorPage

      public static void setCustomErrorPage(String customErrorPage)
      Sets the custom error page URL.
      Parameters:
      customErrorPage - the custom error page URL to set