Jan Kopecký
Jan Kopecký

Reputation: 93

Sniffy filter setup together with encoding filter?

I'm trying to add Sniffy profiler into JSF project.

According to the documentation web.xml needs to be updated with following filter:

<filter>
    <filter-name>sniffer</filter-name>
    <filter-class>io.sniffy.servlet.SnifferFilter</filter-class>
    <init-param>
        <param-name>inject-html</param-name>
        <param-value>true</param-value>
    </init-param>
    <init-param>
        <param-name>enabled</param-name>
        <param-value>true</param-value>
    </init-param>
</filter>
<filter-mapping>
    <filter-name>sniffer</filter-name>
    <url-pattern>/*</url-pattern>
</filter-mapping>

But web.xml already contains one filter:

<filter>
    <filter-name>Character Encoding Filter</filter-name>
    <filter-class>org.primefaces.titan.filter.CharacterEncodingFilter</filter-class>
</filter>
<filter-mapping>
    <filter-name>Character Encoding Filter</filter-name>
    <servlet-name>Faces Servlet</servlet-name>
</filter-mapping>    
<servlet>
    <servlet-name>Faces Servlet</servlet-name>
    <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
</servlet>
<servlet-mapping>
    <servlet-name>Faces Servlet</servlet-name>
    <url-pattern>*.jsf</url-pattern>
</servlet-mapping>
<servlet-mapping>
    <servlet-name>Faces Servlet</servlet-name>
    <url-pattern>*.xhtml</url-pattern>
</servlet-mapping>

When sniffer filter is added (and works correctly) Character Encoding Filter stops working (characters are garbled).

How should web.xml looks like to have both filters working?

Upvotes: 1

Views: 193

Answers (1)

bedrin
bedrin

Reputation: 4586

Sniffy developer here. It is a bug in Sniffy - I plan to fix it in upcoming 3.1 release.

As a workaround you can add following to your JVM arguments:

-Dfile.encoding=UTF-8

Upvotes: 3

Related Questions