Skip to content

InternalResourceView should writer encoding for includes [SPR-4084] #8763

@spring-projects-issues

Description

@spring-projects-issues

Greg Wiley opened SPR-4084 and commented

When InternalResourceView decides to use an include instead of a forward, the output writer encoding can become incompatible with the content type header.

Scenario:

configure an InternalResourceView with:

contentType:   "text/html; charset=UTF-8
alwaysInclude: true

in the target JSP, use:

<%@ page
contentType="text/html; charset=UTF-8"
language="java"%>

or even

<%@ page
contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"
language="java"%>

The resulting content seen by the browser will have headers indicating UTF-8 encoding but the actual content stream will not be so encoded. This might be easily solved by having the InternalResourceResolver set the Response's content type in the include case only (between lines 133 & 134 in the 2.0.6 version). Would this break the code for other purposes?

The trouble I have with making this report is that I'm not sure it should even be the view implementation's responsibility. Rather, I would think that the JSP implementation would be responsible for providing a suitably-encoding writer based on the page directive--even if the implementation had to perform a conversion to merge the stream into the parent's. So I understand if the response here is "not Spring's problem."


Affects: 2.0.6

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions