[jboss-jira] [JBoss JIRA] (WFLY-2550) Setting the response encoding via Filter doesn't work, is always null

Tomaz Cerar (JIRA) jira-events at lists.jboss.org
Fri Nov 22 08:11:06 EST 2013


    [ https://issues.jboss.org/browse/WFLY-2550?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12926063#comment-12926063 ] 

Tomaz Cerar commented on WFLY-2550:
-----------------------------------

[~dxmann73] see also WFLY-2533 which will allow you to set default encoding for deployment / server-wide
                
> Setting the response encoding via Filter doesn't work, is always null
> ---------------------------------------------------------------------
>
>                 Key: WFLY-2550
>                 URL: https://issues.jboss.org/browse/WFLY-2550
>             Project: WildFly
>          Issue Type: Bug
>      Security Level: Public(Everyone can see) 
>          Components: Web (Undertow)
>    Affects Versions: 8.0.0.Beta1
>         Environment: Linux and Windows
>            Reporter: David Mann
>            Assignee: Stuart Douglas
>              Labels: undertow, utf-8
>
> When trying to set the character encoding of the HTTP response, the encoding stays null.
> This is our filter implementation:
> 	public void doFilter(HttpServletRequest request, HttpServletResponse response, HttpSession session,
> 			FilterChain chain) throws ServletException, IOException
> 	{
> 		System.out.println("encoding is " + request.getCharacterEncoding());
> 		if (request.getCharacterEncoding() == null) {
> 			request.setCharacterEncoding("UTF-8");
> 		}
> 		if (request.getCharacterEncoding() == null) {
> 			System.out.println("could not set encoding");
> 			Thread.dumpStack();
> 		}
> 		chain.doFilter(request, response);
> 	}
> The stack trace implies that there is only undertow beneath us ;-) Some element in the chain has already touched the response.
> could not set encoding
> java.lang.Exception: Stack trace
>   at java.lang.Thread.dumpStack(Thread.java:1342)
>   at de.mdkgmbh.sp.MdkCharacterEncodingFilter.doFilter(MdkCharacterEncodingFilter.java:24)
>   at org.omnifaces.filter.HttpFilter.doFilter(HttpFilter.java:75)
>   at io.undertow.servlet.core.ManagedFilter.doFilter(ManagedFilter.java:56)
>   at io.undertow.servlet.handlers.FilterHandler$FilterChainImpl.doFilter(FilterHandler.java:132)
>   at io.undertow.servlet.handlers.FilterHandler.handleRequest(FilterHandler.java:85)
>   at io.undertow.servlet.handlers.security.ServletSecurityRoleHandler.handleRequest(ServletSecurityRoleHandler.java:59)
>   at io.undertow.servlet.handlers.ServletDispatchingHandler.handleRequest(ServletDispatchingHandler.java:36)
>   at org.wildfly.extension.undertow.security.SecurityContextAssociationHandler.handleRequest(SecurityContextAssociationHandler.java:81)
>   at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:25)
>   at io.undertow.servlet.handlers.security.SSLInformationAssociationHandler.handleRequest(SSLInformationAssociationHandler.java:113)
>   at io.undertow.security.handlers.AuthenticationCallHandler.handleRequest(AuthenticationCallHandler.java:52)
>   at io.undertow.security.handlers.AbstractConfidentialityHandler.handleRequest(AbstractConfidentialityHandler.java:45)
>   at io.undertow.servlet.handlers.security.CachedAuthenticatedSessionHandler.handleRequest(CachedAuthenticatedSessionHandler.java:65)
>   at io.undertow.security.handlers.SecurityInitialHandler.handleRequest(SecurityInitialHandler.java:70)
>   at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:25)
>   at io.undertow.server.handlers.PredicateHandler.handleRequest(PredicateHandler.java:25)
>   at io.undertow.servlet.handlers.ServletInitialHandler.handleFirstRequest(ServletInitialHandler.java:218)
>   at io.undertow.servlet.handlers.ServletInitialHandler.dispatchRequest(ServletInitialHandler.java:205)
>   at io.undertow.servlet.handlers.ServletInitialHandler.access$000(ServletInitialHandler.java:69)
>   at io.undertow.servlet.handlers.ServletInitialHandler$1.handleRequest(ServletInitialHandler.java:134)
>   at io.undertow.server.HttpHandlers.executeRootHandler(HttpHandlers.java:36)
>   at io.undertow.server.HttpServerExchange$1.run(HttpServerExchange.java:619)
>   at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
>   at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
>   at java.lang.Thread.run(Thread.java:722)
> We need a solution for this, as we rely on UTF-8.
> We have found no way to configure the listener either, seeing that the old JBoss Web way doesn't work anymore (WFLY-2276)

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira


More information about the jboss-jira mailing list