Setting content-type http header in Weblogic 8 to fix angular html encoding issue

2.5k views Asked by At

I have an angular app being deployed from a weblogic 8 server. However in UAT there is an encoding issue in one of the html files. We have ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖØÙÚÛÜÝ in an ng-pattern for validation but when we look at it using developer tools some of them are being interpreted as □?.

I have saved the html file as UTF-8 and run Jenkins. As part of our build process a grunt command runs that combines all our js and htlm into one file. Visual inspection of this file shows that the encoding is still good. The .js file produced is UTF-8 and there are no □? symbols.

I think the browsers in UAT are reading the file as ISO-8895 encoding instead of UTF-8. I found a solution. By setting the content-type http header to "text/html; charset=utf-8" I can force the browser to use the right encoding. I couldn't find a config in weblogic 8 to set this header so I made the following servlet filter:

https://github.com/pacurtin/HttpHeaderFilterServlet/blob/master/src/com/paddycurtin/HttpHeaderFilter.java

This works in tomcat and for .do struts files in weblogic but not for .html files. Debugging through the code shows that the header is being set to "text/html; charset=utf-8" but then weblogic is resetting it to "text/html".

Is there a way to set the content-type http header in weblogic 8? Or a way to stop it overwriting "text/html; charset=utf-8" with "text/html"?

Is this servlet filter approach the wrong way to approach this encoding issue?

1

There are 1 answers

2
Gatusko On

Here are the steps on how encode in WebLogic server

Setting a WebLogic Server System Property

You can also specify the character set for all deployed WebLogic Web Services deployed on a WebLogic Server instance by setting the system property weblogic.webservice.i18n.charset equal to the name of the character set. Set this system property in the script that starts up the WebLogic Server instance:

-Dweblogic.webservice.i18n.charset=utf-8

Here are more how to put as default in other servers UTF-8 Configuration and here is the documentation of how to Internationalization in WebLogic Documentation of Weblogic I hope this helps. Well if the script doesn't work try this to adding to your weblogic.xml:

<charset-params> 
    <input-charset> 
        <resource-path>/*</resource-path> 
        <java-charset-name>UTF-8</java-charset-name> 
    </input-charset> 
</charset-params>

Check this doc for the configuration of the weblogic.xml

weblogic.xml Doc