I have a Servlet and a Servlet Filter that is supposed to apply an xsl to it. The transformation appears to work, I get back a transformed document, but it appears (in IE) as if IE thinks its an HTML document. Viewing source, and saving as an HTML file will display correctly. How can I correctly set the Content Type of the response?

Vincent Fischer

 

 

I figured this out. Many thanks go out to Matan Amir for pointing me in the right direction.

I used Ethereal (I couldn't get tcptrace to work), to verify that in fact the content type was "text/xml", instead of "text/html". So, I finally figured out that instead of:

response.setContentType("text/html");
I wrote:

wrapper.setContentType("text/html");


I'm guessing the reason is because the response and request objects in the Filter cannot be modified... So instead, I made the changes to the wrapper. Of course, if I'd set my servlet to send the response as "text/html" this would work too, but the purpose of the assignment was to change the contentType...

[See http://www.jguru.com/forums/view.jsp?EID=1072839 for the source code and more discussion. -Alex]

[Todo: add "Filters" category; add this to it]

0 Comments  (click to add your comment)
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

About | Sitemap | Contact