0
votes

I have a simple form submit request. Before the request is receiving to Servlet it is going through the Filter. In that Filter I am setting charset encoding as "iso-8859-15", because of this charset encoding the request parameter value is not encoding properly.

public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse,
            FilterChain chain) throws IOException {
        servletRequest.setCharacterEncoding("iso-8859-15");

For example, I have parameter value as “1Depósito” and is encoding wrongly to “1Depósito” instead of “1Depósito”. Because I have some international language special character (i.e. "ó") in my request parameter value.

As per my google research, the input request encoding is UTF-8 but in filter we are setting different encoding i.e. iso-8859-15 hence it might be not encoding properly. But this issue we can see only when running in WebLogic 10. The same code is running fine when it run in spring-boot embedded Tomcat

NOTE:

  1. If i set the character Encoding as UTF-8 in my filter it is working fine even in WebLogic also but like to know how "iso-8859-15" encoding is working in Tomcat but not in Weblogic?
  2. In both WebLogic & Tomcat the input request content type is same as shown below:

    • Content-Type: application/x-www-form-urlencoded; charset=UTF-8
  3. Then why the setCharacterEncoding is failing only in WebLogic not in Tomcat?

Do we have any default encoding settings for spring-boot embedded Tomcat server?

How could I fix this issue in my WebLogic deployment?

Looking forward to your valuable inputs.

Thanks, BSK

1
How are you configuring / applying this filter? The default encoding set through a pre-configured CharacterEncodingFilter is UTF-8 .M. Deinum
The filter is configured in my web.xml file which maps for all the requests (i.e. /*.*). we didn't configured CharacterEncodingFilterBaji Shaik
And that is your answer... Embedded tomcat doesn't do anything with web.xml so it uses the default configuration CharacterEncodingFilter and not your own filter. Also when using a web.xml with Spring Boot make sure you are using Spring Boot Legacy to properly bootstrap it. Or ditch it and use the proper way to bootstrap it as documented here.M. Deinum
You mean, if I configure the CharacterEncodingFilter in my web.xml will it fix the encoding issue when I run in WebLogic build?Baji Shaik
Well yes, but I would suggest reading the documentation on how to properly start the spring boot application. As you are now basically running a differently configured application in dev and production.M. Deinum

1 Answers

0
votes

Better late than never.

But this issue we can see only when running in WebLogic 10. The same code is running fine when it run in spring-boot embedded Tomcat

Web Logic either takes character set config from WebLogic Server System Property or from weblogic.xml

On the other hand Embedded Tomcat ignores weblogic.xml

Fix

Either provide character set in weblogic.xml or as WebLogic Server System Property.

  • WebLogic Server System Property
-Dweblogic.webservice.i18n.charset=utf-8
  • weblogic XML Config
    <charset-params>
        <input-charset>
            <resource-path>/*</resource-path>
            <java-charset-name>UTF-8</java-charset-name>
        </input-charset>
    </charset-params>
  • Docs

Internationalizing a WebLogic Web Service
weblogic.xml - charset-params