> you need a wrapper for the response object. 
> 

Sorry, I can't understand how it works yet :-(

Anyway, I wrote  wrapper:

import javax.servlet.http.*;

public class MyResponseWrapper extends HttpServletResponseWrapper
{

     public MyResponseWrapper(HttpServletResponse response) {
       super(response);
     }

     private String saveContentType = null;

     public String getContentType() {
       return (this.saveContentType);
     }

     public void setContentType(String contentType) {
       super.setContentType(contentType);
       this.saveContentType = contentType;
     }

}


Then I try to use it:

    public void doFilter(ServletRequest request, ServletResponse response,
                          FilterChain chain)
         throws IOException, ServletException {
       MyResponseWrapper wresponse =
        new MyResponseWrapper((HttpServletResponse) response);

         chain.doFilter(request, wresponse);
         wresponse.setContentType("text/xml;charset=windows-1251");
     }


This works for html pages, but doesn't work for jsp!
I don't know why, but jsps still have type text/html :-(

Could you help me?





> see this post in the archives:
> http://www.mail-archive.com/tomcat-user@jakarta.apache.org/msg41615.html
> 
> Charlie
> 
>> -----Original Message-----
>> From: Dmitry Melekhov [mailto:[EMAIL PROTECTED]]
>> Sent: Friday, July 19, 2002 1:48 AM
>> To: [EMAIL PROTECTED]
>> Subject: filter to set content type
>> 
>> 
>> Hello!
>> 
>> I need to filter jsp output to set  encoding in content type.
>> I tryied several variants I can write ;-) with no success :-(
>> 
>> Could somebody send me an example?
>> 
>> Thank you!
>> 
>> 



--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to