Encoding Filter ver. 1.4


This is a Java servlet filter (as per Servlet API 2.3). EncodingFilter lets you specify character encoding for all input fields in your JSP pages. It is very common problem in case of you need to support localized pages. With such encoding any request.getParameter() call will read data in the proper form.

How to use it:

a) download encflt.jar and save it in WEB-INF/lib

b) describe this filter in web.xml. Initial parameter (name is encoding) describes your encoding (e.g. UTF8, Big5 etc.)
 


<filter>
  <filter-name>EncodingFilter</filter-name>
  <filter-class>com.cj.encflt.EncodingFilter</filter-class>
  <init-param>
    <param-name>encoding</param-name>
    <param-value>your_encoding</param-value>
  </init-param>
</filter>

c) describe a mapping for this filter in web.xml
 


<filter-mapping>
  <filter-name>EncodingFilter</filter-name>
  <url-pattern>/*.jsp</url-pattern>
</filter-mapping>

in this case filter will be on for each your .jsp file

And now when you invoke any .jsp page: http://your_host/your_page.jsp EncodingFilter will set character encoding for input fields to the value described in the filter's initial parameter.

Also you may exclude some of your files from the processing. Parameter exclude contains a commas separated list of files excluded from the processing.

   For downloading:
    Filter:  encflt.jar

 ©  Coldbeans     Comments?

See also JSOS - the largest collection of servlets and filters.

Also in JSOS: