Proper activeweb configuration for pages with foreign language characters

72 views Asked by At

I have just created new web application based on activeweb framework and by default it shows me "?" for all foreign language characters. Something like this:

? ????????? ?????? ???? ????????? ?? ?????? ??????????

? ??? ???? ?????????? ??????????? ????????

English characters are displayed ok.

Here is my web.xml config:

<display-name>activeweb</display-name>

<session-config>
    <session-timeout>30</session-timeout>
</session-config>


<filter>
    <filter-name>dispatcher</filter-name>
    <filter-class>org.javalite.activeweb.RequestDispatcher</filter-class>
    <init-param>
        <param-name>exclusions</param-name>
        <param-value>css,img,fonts,images,js,html,GwtExample,ico</param-value>
    </init-param>
    <init-param>
        <param-name>root_controller</param-name>
        <param-value>home</param-value>
    </init-param>
</filter>


<filter-mapping>
    <filter-name>dispatcher</filter-name>
    <url-pattern>/*</url-pattern>
</filter-mapping>

<welcome-file-list>
    <welcome-file>index.jsp</welcome-file>
</welcome-file-list>

I expect that this problem might be related to encoding in activeweb internals or I have to apply special setting. Do you know how to fix it?

1

There are 1 answers

0
ipolevoy On BEST ANSWER

This happens because ActiveWeb does nothing about encoding by default, and what you get comes from the servlet container.In order to force a specific encoding (UTF-8, I assume), you need to add a line of configuration to the web.xml file:

<filter> <filter-name>dispatcher</filter-name> <filter-class>org.javalite.activeweb.RequestDispatcher</filter-class> <init-param> <param-name>exclusions</param-name> <param-value>css,images,js,ico</param-value> </init-param> <init-param> <param-name>root_controller</param-name> <param-value>home</param-value> </init-param> <init-param> <param-name>encoding</param-name> <param-value>UTF-8</param-value> </init-param> </filter>

This will force UTF-8 encoding on request as well as response.