-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
The content type of page directive in jsp code is ignored. #22
Comments
Comment by lefloh: Thanks for reporting. I started a discussion in the (https://java.net/projects/mvc-spec/lists/users/archive/2016-03/message/15). |
A few thoughts on this one: The pull request mvc-spec/mvc-spec#132 will change how view engines write the result of processing the view to the client. So handling of content type and charset is much more explicit. IMHO the content type and encoding negotiation should be done by JAX-RS. That's how it works for all other JAX-RS responses. Perhaps we could simply prevent that the JSP directives do any harm by modifying |
To sum up the discussion as the old mailing list is gone: We have two ways to specify the response encoding:
The spec only states:
I'm with Christian and would also prefer to specify the encoding in a controller. But other developers might prefer the other way. Instead of defining strict rules which way wins I'd propose that view engines should ensure encoding works or otherwise log a warning:
This means that there could be view engines which support both ways but also some which support only one way. I'm not too strong on this one if anyone comes up with a better solution. |
Hi @lefloh, thanks for the great summary. I just saw that the original issue is over 3 years old. So we should finally try to fix this. :-) Let my try to explain what my understanding of the response media type handling in plain JAX-RS is.
So for JAX-RS there are many places where the response media type can be set. And actually it is very well-defined who wins, as all these steps are executed in order and every stage can change the media type set by the previous stage. What does this mean for MVC? Perhaps we should simply do it the same way. And actually I think that we are already doing it almost exactly like that.
I think Krazo is currently handling 1-3 perfectly fine. And that's great. The only thing we have to ensure is that 4 works correctly. And IMO there are two cases.
To sum up. I don't think that we need to change anything on the specification level. And we don't need to define where setting the media type and encoding is allowed and where it is not. We just need to ensure that the last component in the chain (which is the MBW/ViewEngine) correctly applies the value provided by the previous components AND also allow to change it even in the case of Servlet forwards (which could be more or less). Sorry for the long text. Any thoughts? :-) |
Thanks for your detailed response @chkal! Thought about this for a while and it absolutely makes sense. |
Hi @chkal, Intercepting What still does not work is using a JSP without a Thoughts? |
Hey @lefloh. Sorry for the delayed response. Thank you so much for spending time on this issue. I'll try to find some time at the weekend to have a deeper look at this. I guess I need to dig a bit deeper into the topic to give qualified thoughts. :-) |
You were waiting for more than one year for my response so no need to say sorry ;-) |
Hey @lefloh, I just had a deeper look at your changes. I think you are definitely on the right track. 🍻 A few thoughts regarding your questions:
Creating the Maybe we can store the "current" charset in a field in
If my understanding is correct and if the JSP engines always uses |
Hi @chkal, thanks for your suggestions! I updated the PR. Is this how you expected it?
|
Tuesday Jan 05, 2016 at 02:06 GMT
Originally opened as mvc-spec/ozark#83
Original issue OZARK-67 created by kogawa88:
When fowarding the following jsp page via Ozark, the response always writes the body content with UTF-8 encoding.
This jsp returns the response with Shift_JIS charset encoding.
The issue can be avoided using JAX-RS api, but it means duplicate declaration of the content type concurrently.
|| How to declare page uri || ||
| @view annotation | Declare @produces("text/html; charset=Shift_JIS"). |
| Return of uri string | Declare @produces("text/html; charset=Shift_JIS"). |
| Return of JAX-RS response | Set the MediaType.TEXTHTML_TYPE with ShiftJIS charset to the response. |
There is no problem if using servlet based MVC framework (like Struts).
The text was updated successfully, but these errors were encountered: