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 8264647
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T04:31:56+00:00 2026-06-08T04:31:56+00:00

I got a strange issue with wrong URI Encoding and would appreciate any help!

  • 0

I got a strange issue with wrong URI Encoding and would appreciate any help!

The project uses JSPs, Servlets, Jquery, Tomcat 6.

Charset in the JSPs is set to UTF-8, all Tomcat connectors use URIEncoding=UTF-8 and I also use a character encoding filter as described here.
Also, I set the contentType in the meta Tag and my browser detects it correctly.

In Ajax calls with Jquery I use encodeURIComponent() on the terms I want to use as URL Parameters and then serialize the whole parameter set with $.param(). In the called servlet these parameters are decoded correctly with Java.net.URLDecoder.decode(term, “UTF-8”).

In some places I generate URLs for href elements from a parameter map in the JSPs. Each parameter value is encoded with Java.net.URLEncoder.encode(value, “UTF-8”) on JSP side but then decoding it the same way as before results in broken special characters. Instead, I have to encode it as “ISO-8859-2” in the JSP which is then decoded correctly as “UTF-8” in the servlet.

An example for clarifying:
The term “überfall” is URIEncoded via Javascript (%C3%BCberfall) and sent to the servlet for decoding and processing, which works. After passing it back to a JSP I would encode it as UTF-8 and build the URL which results for instance in:

<a href="/myWebapp/servletPath?term=%C3%BCberfall">Click here</a>

However, clicking this link will send the parameter as “%C3%83%C2%BCberfall” to the servlet which decodes to “überfall”. The same occurs when no encoding takes place.

When, using “ISO-8859-2” for encoding I get:

<a href="/myWebapp/servletPath?term=%FCberfall">Click here</a>

When clicking this link I can observe in Wireshark that %C3%BCberfall is sent as parameter which decodes again to “überfall”!

Can anyone tell me where I miss something?

EDIT:
While observing the Network Tab in Firebug I realized that by using

$.param({term : encodeURIComponent(term)}); 

the term is UTF-8 encoded twice, resulting in “%25C3%25BCberfall”, i.e. the percent symbols are also percent-encoded. Analogously, it works for me if I call encode(term, “UTF-8”) twice on each value from the parameter map.

Encoding once and not decoding the String results in “überfall” again.

  • 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-08T04:31:58+00:00Added an answer on June 8, 2026 at 4:31 am

    I think I fixed the problem now definitely.

    Following Jontro’s comment I encoded all URL parameter values once and removed the manual servlet-side decoding.

    Sending an ü should look like %C3%BC in Firebug’s Network tab which gave me ü in the servlet.
    Java was definitely set to “UTF-8” internal encoding with the -Dfile.encoding parameter.
    I traced the problem to the request.getParameter() method like this. request.getQueryString was ok, but when extracting the actual parameters it fails:

    request.getCharacterEncoding()) => UTF-8
    request.getContentType() => null
    request.getQueryString() => from=0&resultCount=10&sortAsc=true&searchType=quick&term=%C3%BC
    request.getParameter(“term”) => ü
    Charset.defaultCharset() => UTF-8
    OutputStreamWriter.getEncoding() => UTF8
    new String(request.getParameter(“term”).getBytes(), UTF-8) => ü
    System.getProperty(“file.encoding”) => UTF-8

    By looking into the sources of Tomcat and Coyote which implement request.getParameter() i found the problem: the URIEncoding from the connector was always null and in this case it defaults to org.apache.coyote.Constants.DEFAULT_CHARACTER_ENCODING which is “ISO-8859-1” like Wolfram said.

    Long story short: my fault was editing the server.xml in Tomcat’s conf directory which is only loaded ONCE into Eclipse when a new server is created in the servers view! After that, a separate server.xml in the Servers project has to be edited. After doing so, the connector setting is loaded correctly and everything works as it should.

    Thanks for the comments! Hope this helps someone…

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

Sidebar

Related Questions

Ok I got a strange issue that I hope someone could help with I
I've got a pretty strange issue in my first try of using Entity Framework
I've got strange issue. I want wait end async call at sync function call.
I have this very strange issue with my MVC 2 project. Often times, I'll
I got a strange issue. I am inserting a new object into my Core
I've got a strange issue with decoding an escaped javascript string. Here is the
got a strange issue for you. I created a control that inserts a record
I've got a very strange issue while parsing an external XAML file. The pre-history
I've got strange issue - I hope someone run similar problem before. I'm trying
I've got a strange issue. I've setup XDebug to profile a PHP application we're

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.