I am using Struts 1.2.7
I wrote a Filter which intercepts all requests and applies response headers
(based on some external configuration) to it. All response headers applied
in my Filter other than "Content-Type" were obeyed and sent to the client.
Content-Type was always "text/html".
After a lot of debugging, I realized the value for this particular header
are always getting overwritten in the struts' RequestProcessor class.
Underneath is the method which in my case turned out to be the "culprit"
>
> protected void processContent(HttpServletRequest request,
> HttpServletResponse response) {
> String contentType =
> moduleConfig.getControllerConfig().getContentType();
> if (contentType != null) {
> response.setContentType(contentType);
> }
> }
>
Couple of questions:
1. Shouldn't this method also check if the response already has a
contentType header applied or not? Is this a known bug, or am I missing
something?
2. I subclassed the RequestProcessor and defined a controller in my
struts config as <controller processorClass="com.me.MyRequestProcessor"/>.
The class merely overrides the processContent method to check for an
existing contentType. Am I doing it correctly, or is there some other way to
achieve the desired behavour in my case.
Cheers
Avlesh