Package com.jk.web.mvc
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 -
Method Summary
Modifier and TypeMethodDescriptionvoid
destroy()
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.
-
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 interfacejakarta.servlet.Filter
- Parameters:
filterConfig
- aFilterConfig
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 interfacejakarta.servlet.Filter
- Parameters:
request
- theServletRequest
object contains the client's request.response
- theServletResponse
object contains the filter's response.chain
- theFilterChain
for invoking the next filter or the resource.- Throws:
IOException
- if an I/O related error has occurred during the processingjakarta.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 interfacejakarta.servlet.Filter
-