Class MvcFilter

java.lang.Object
com.jk.web.mvc.MvcFilter
All Implemented Interfaces:
jakarta.servlet.Filter

@WebFilter(urlPatterns="*.jsp") public class MvcFilter extends Object implements jakarta.servlet.Filter
This class is a Servlet Filter that handles Model-View-Controller (MVC) bindings and filtering of JSP pages.
Version:
1.0
Author:
Dr. Jalal H. Kiswani
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    This method destroys the filter.
    void
    doFilter(jakarta.servlet.ServletRequest request, jakarta.servlet.ServletResponse response, jakarta.servlet.FilterChain chain)
    This method filters incoming requests, initializes MVC bindings, and processes JSP pages.
    void
    init(jakarta.servlet.FilterConfig filterConfig)
    This method initializes the filter and scans for MVC models in specified packages.

    Methods inherited from class java.lang.Object

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

    • MvcFilter

      public MvcFilter()
  • Method Details

    • init

      public void init(jakarta.servlet.FilterConfig filterConfig) throws jakarta.servlet.ServletException
      This method initializes the filter and scans for MVC models in specified packages.
      Specified by:
      init in interface jakarta.servlet.Filter
      Parameters:
      filterConfig - a FilterConfig object containing the filter's configuration and initialization parameters.
      Throws:
      jakarta.servlet.ServletException - if an exception has occurred that interferes with the filter's normal operation.
    • doFilter

      public void doFilter(jakarta.servlet.ServletRequest request, jakarta.servlet.ServletResponse response, jakarta.servlet.FilterChain chain) throws IOException, jakarta.servlet.ServletException
      This method filters incoming requests, initializes MVC bindings, and processes JSP pages.
      Specified by:
      doFilter in interface jakarta.servlet.Filter
      Parameters:
      request - the ServletRequest object contains the client's request.
      response - the ServletResponse object contains the filter's response.
      chain - the FilterChain for invoking the next filter or the resource.
      Throws:
      IOException - if an I/O related error has occurred during the processing
      jakarta.servlet.ServletException - if an exception occurs that interferes with the filter's normal operation.
    • destroy

      public void destroy()
      This method destroys the filter.

      Called by the web container to indicate to a filter that it is being taken out of service.

      This method is only called once all threads within the filter's doFilter method have exited or after a timeout period has passed.

      After the web container calls this method, it will not call the doFilter method again on this instance of the filter.

      Specified by:
      destroy in interface jakarta.servlet.Filter