I'm trying to persuade a SiteMesh decorator to change the content-type of the response, but no joy. The content-type always ends up being the same as the decorated JSP, rather than that of the decorator.
For example, say I have a JSP with the header
<%@ page contentType="application/xhtml+xml" %>
I also have a SiteMesh decorator JSP which defines this:
<%@ page contentType="application/vnd.wap.xhtml+xml" %>
What I want is for the decorated response to have the mime type of the decorator (the actual MIME type used here are not important, this is just to illustrate the problem).
A dig through the SiteMesh 2.4.1 source suggests that the problem lies with the ContentBufferingResponse
class, which is responsible for capturing the output of the target. This overrides the setContentType()
method, recording the value for later use, but it also invokes super.setContentType()
, effectively passing the content-type of the target JSP directly to the response. Once that's done, no amount of cajoling will persuade the response to do otherwise.
So is there a workaround for this? Can the content-type of the target JSP be suppressed, and taken from the decorator instead?