I have a Tapestry application that is serving its page as UTF-8. That is, server responses have header:
Content-type: text/html;charset=UTF-8
Now within this application there is a single page that should be served with ISO-8859-1 encoding. That is, server response should have this header:
Content-type: text/html;charset=ISO-8859-1
How to do this? I don’t want to change default encoding for whole application.
Based on google searching I have tried following:
@Meta({ 'org.apache.tapestry.output-encoding=ISO-8859-1', 'org.apache.tapestry.response-encoding=ISO-8859-1', 'org.apache.tapestry.template-encoding=ISO-8859-1', 'tapestry.response-encoding=ISO-8859-1'}) abstract class MyPage extends BasePage { @Override protected String getOutputEncoding() { return 'ISO-8859-1'; } }
But neither setting those values with @Meta annotation or overriding getOutputEncoding method works.
I am using Tapestry 4.0.2.
EDIT: I ended up doing this with a Servlet filter with subclassed HttpServletResposeWrapper. The wrapper overrides setContentType() to force required encoding for the response.
Have you considered a Filter? Maybe not as elegant as something within Tapestry, but using a plain Filter, that registers the url mapping(s) of interest. One of its init parameters would be the encoding your after. Example: