[ https://issues.apache.org/jira/browse/MYFACES-4214?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16419295#comment-16419295 ]
Kyle Stiemann commented on MYFACES-4214: ---------------------------------------- A similar bug exists in Mojarra but only for {{execute="@all"}} Ajax requests/responses: https://github.com/javaserverfaces/mojarra/issues/4358. > The wrong content type of "text/html" is set for Ajax requests > -------------------------------------------------------------- > > Key: MYFACES-4214 > URL: https://issues.apache.org/jira/browse/MYFACES-4214 > Project: MyFaces Core > Issue Type: Bug > Components: General, Portlet_Support > Affects Versions: 2.2.12, 2.3.0 > Reporter: Kyle Stiemann > Priority: Minor > > h2. Steps to reproduce: > # Clone the > [wrong-content-type-ajax-excecute-all-reproducer|https://github.com/stiemannkj1/wrong-content-type-ajax-excecute-all-reproducer] > project: > {code} > git clone > https://github.com/stiemannkj1/wrong-content-type-ajax-excecute-all-reproducer.git > {code} > # Build the project: > {code} > cd wrong-content-type-ajax-excecute-all-reproducer && mvn clean package -P > myfaces > {code} > # Deploy the project to Tomcat: > {code} > cp target/*.war > $TOMCAT_HOME/webapps/wrong-content-type-ajax-excecute-all-reproducer.war > {code} > # Navigate to the deployed webapp at > [http://localhost:8080/wrong-content-type-ajax-excecute-all-reproducer/|http://localhost:8080/wrong-content-type-ajax-excecute-all-reproducer/]. > # Note that the _External Context Calls:_ show that > \{{setResponseContentType("text/html")}} was correctly called before the > first call to \{{getResponseOutputWriter()}}. > # Click the _Execute (default) Ajax Request_ button. > # Note the _External Context Calls:_. > # Click the _Execute @all Ajax Request_ button. > If the bug still exists, the _External Context Calls:_ will show that > \{{setResponseContentType("text/html")}} was *incorrectly* called before the > first call to getResponseOutputWriter()` during Ajax requests. > If the bug is fixed, the _External Context Calls:_ will show that > \{{setResponseContentType("text/xml")}} was called immediately before the > first call to \{{getResponseOutputWriter()}}. > h2. Additional Information: > The Servlet 3.1 Specification states (in section _5.5 Internationalization_): > {quote} > The \{{setCharacterEncoding}}, \{{setContentType}}, and \{{setLocale}} > methods can be called repeatedly to change the character encoding. Calls made > after the servlet response’s \{{getWriter}} method has been called or after > the response is committed have no effect on the character encoding. > {quote} > Therefore, before the first call to > \{{externalContext.getResponseOutputWriter()}}, > \{{externalContext.setResponseContentType()}} must be called with the correct > content type. > Although this bug does not seem to break anything, that's likely because > servlet implementations do not perfectly implement the requirements of the > servlet spec. This does cause issues in Servlet and Portlet Containers (such > as Liferay) that correctly implement their respective specs. -- This message was sent by Atlassian JIRA (v7.6.3#76005)