Package com.jk.web.filters
Class JKSetCharacterEncodingFilter
java.lang.Object
com.jk.web.filters.JKSetCharacterEncodingFilter
- All Implemented Interfaces:
jakarta.servlet.Filter
This class is a Java Servlet filter that sets the character encoding for
incoming requests.
- Version:
- 1.0
- Author:
- Dr. Jalal H. Kiswani
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected StringRepresents the encoding.protected jakarta.servlet.FilterConfigRepresents the filter configuration.protected booleanIndicates whether to ignore the filter or not. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoiddestroy()voiddoFilter(jakarta.servlet.ServletRequest request, jakarta.servlet.ServletResponse response, jakarta.servlet.FilterChain chain) voidinit(jakarta.servlet.FilterConfig filterConfig) protected StringselectEncoding(jakarta.servlet.ServletRequest request) This method selects the character encoding.
-
Field Details
-
encoding
Represents the encoding. -
filterConfig
protected jakarta.servlet.FilterConfig filterConfigRepresents the filter configuration. -
ignore
protected boolean ignoreIndicates whether to ignore the filter or not.
-
-
Constructor Details
-
JKSetCharacterEncodingFilter
public JKSetCharacterEncodingFilter()
-
-
Method Details
-
destroy
public void destroy()- Specified by:
destroyin interfacejakarta.servlet.Filter
-
doFilter
public void doFilter(jakarta.servlet.ServletRequest request, jakarta.servlet.ServletResponse response, jakarta.servlet.FilterChain chain) throws IOException, jakarta.servlet.ServletException - Specified by:
doFilterin interfacejakarta.servlet.Filter- Throws:
IOExceptionjakarta.servlet.ServletException
-
init
public void init(jakarta.servlet.FilterConfig filterConfig) throws jakarta.servlet.ServletException - Specified by:
initin interfacejakarta.servlet.Filter- Throws:
jakarta.servlet.ServletException
-
selectEncoding
This method selects the character encoding.- Parameters:
request- Specifies the servlet request.- Returns:
- the selected character encoding.
-