Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8528893
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T08:54:17+00:00 2026-06-11T08:54:17+00:00

I face this problem. I have a filter that sets the character encoding of

  • 0

I face this problem. I have a filter that sets the character encoding of the request according to the filter’s config (for example, to UTF-8). This works with forms coded using the struts html:form tag. However, if I use the ordinary HTML form tag, the data are not encoded correctly.

This is the filter definition in the web.xml:

<filter>
    <filter-name>Encoding Filter</filter-name>
    <filter-class>EncodingFilter</filter-class>
    <init-param>
        <param-name>encoding</param-name>
        <param-value>UTF-8</param-value>
    </init-param>
 </filter>
 <filter-mapping>
    <filter-name>Encoding Filter</filter-name>
    <url-pattern>/*</url-pattern>
 </filter-mapping>

Here’s the filter :

public class EncodingFilter implements javax.servlet.Filter {
private String encoding;
public void init(FilterConfig filterConfig) throws ServletException {
    this.encoding = filterConfig.getInitParameter("encoding");
}
public void doFilter(ServletRequest request, ServletResponse response, FilterChain filterChain) throws IOException, ServletException {
    request.setCharacterEncoding(encoding);
    filterChain.doFilter(request, response);
}
public void destroy() {
}

}

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T08:54:18+00:00Added an answer on June 11, 2026 at 8:54 am

    If you use a Struts tag <html:form> and omit the METHOD attribute it defaults to POST.
    If you use a standard HTML <form> and omit the METHOD attribute it defaults to GET.

    Tomcat will process your POST and GET parameters differently:

    POST: your filter will be used. Note that you should really only set the request character encoding if it has not been specified by the client (your filter is always setting it to UTF-8). Tomcat comes with a filter SetCharacterEncodingFilter.java that does this.

    GET: Tomcat will use ISO-8859-1 as the default character encoding. There are two ways to specify how GET parameters are interpreted:

    • Set the URIEncoding attribute on the element in server.xml to something specific (e.g. URIEncoding=”UTF-8″).
    • Set the useBodyEncodingForURI attribute on the element in server.xml to true. This will cause the Connector to use the request body’s encoding for GET parameters.

    This is all in: http://wiki.apache.org/tomcat/FAQ/CharacterEncoding

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I didn't face this error before. I have a database db , that contains
For this question, let us assume that we will want to show the face
I have a cloud of points that are supposed to represent a face. I
I have this weird problem as to how to name objects of a class.
I have two sets of data in this form: x | y | z
I'm using a font in my site: http://www.fontsquirrel.com/fonts/Bentham But I have a problem: This
I was analyzing my situation and I face with the problem that I need
I am using Eclipse Indigo for Android development. The problem i face is that
I often face this problem with git: I clone a git repo of some
ohk i am facing this very weird problem . i have a cloud server

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.