You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by "Mark W. Webb" <ma...@dolphtech.com> on 2003/04/22 21:09:09 UTC

home grown filter not setting contentType properly

I have written a filter for tomcat that will convert all <,>,& and " to 
&lt, &gt, &amp, and &quot.

The filter converts all the HTML fine when it gets to the browser, but 
the browser displays the actual HMTL code, not the processed page.  I 
thought that this was because I was not setting the contentType, but I 
have verified that this is being set to "text/html".  I have even 
printed out what the contentType gets set to in catalina.out.

I have the following files :

HTMLFilter implements Filter
HTMLFilterWrapper extends HttpServletResponseWrapper
HTMLFilterOutputStream extends ServletOutputStream

any ideas ?

thanks in advance :)



---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Re: home grown filter not setting contentType properly

Posted by "Andre E. Bar'yudin" <ba...@pob.huji.ac.il>.
Квотироние "Mark W. Webb" <ma...@dolphtech.com>:

> that is what I did.  That all works fine.  The <,>,",& show up in my 
> browser window, view source shows &lt,&gt,&quot,&amp.
> The problem is that I get the raw HTML shown in my browser, and not the 
> formatted HTML.  For instance, when I should be seeing a table in my 
> browser, I see <table><tr>....

That's because you've escaped all <,> etc. - so the HTML tags are no longer HTML
tags, but ordinary text.
 
> Andre E. Bar'yudin wrote:
> 
> >Квотироние "Mark W. Webb" <ma...@dolphtech.com>:
> >
> >  
> >
> >>I have written a filter for tomcat that will convert all <,>,& and " to 
> >>&lt, &gt, &amp, and &quot.
> >>
> >>The filter converts all the HTML fine when it gets to the browser, but 
> >>the browser displays the actual HMTL code, not the processed page.  I 
> >>thought that this was because I was not setting the contentType, but I 
> >>have verified that this is being set to "text/html".  I have even 
> >>printed out what the contentType gets set to in catalina.out.
> >>
> >>I have the following files :
> >>
> >>HTMLFilter implements Filter
> >>HTMLFilterWrapper extends HttpServletResponseWrapper
> >>HTMLFilterOutputStream extends ServletOutputStream
> >>
> >>any ideas ?
> >>    
> >>
> >
> >As far as I understand, you simply convert everything, including the tag
> >delimiters, so instead of "<body>" you get "&lt;body&gt;", and this is
> exactly
> >what your browser shows to you.  Try the "View source" function to check
> this.
> >
> >Regards,
> >
> >Andre.
> >
> >  
> >
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
> 
> 


-- 
=============================================================
Andre E. Bar'yudin
Home page:  http://www.cs.huji.ac.il/~baryudin/


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Re: home grown filter not setting contentType properly

Posted by "Mark W. Webb" <ma...@dolphtech.com>.
that is what I did.  That all works fine.  The <,>,",& show up in my 
browser window, view source shows &lt,&gt,&quot,&amp.
The problem is that I get the raw HTML shown in my browser, and not the 
formatted HTML.  For instance, when I should be seeing a table in my 
browser, I see <table><tr>....


Andre E. Bar'yudin wrote:

>Квотироние "Mark W. Webb" <ma...@dolphtech.com>:
>
>  
>
>>I have written a filter for tomcat that will convert all <,>,& and " to 
>>&lt, &gt, &amp, and &quot.
>>
>>The filter converts all the HTML fine when it gets to the browser, but 
>>the browser displays the actual HMTL code, not the processed page.  I 
>>thought that this was because I was not setting the contentType, but I 
>>have verified that this is being set to "text/html".  I have even 
>>printed out what the contentType gets set to in catalina.out.
>>
>>I have the following files :
>>
>>HTMLFilter implements Filter
>>HTMLFilterWrapper extends HttpServletResponseWrapper
>>HTMLFilterOutputStream extends ServletOutputStream
>>
>>any ideas ?
>>    
>>
>
>As far as I understand, you simply convert everything, including the tag
>delimiters, so instead of "<body>" you get "&lt;body&gt;", and this is exactly
>what your browser shows to you.  Try the "View source" function to check this.
>
>Regards,
>
>Andre.
>
>  
>


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Re: home grown filter not setting contentType properly

Posted by "Andre E. Bar'yudin" <ba...@pob.huji.ac.il>.
Квотироние "Mark W. Webb" <ma...@dolphtech.com>:

> I have written a filter for tomcat that will convert all <,>,& and " to 
> &lt, &gt, &amp, and &quot.
> 
> The filter converts all the HTML fine when it gets to the browser, but 
> the browser displays the actual HMTL code, not the processed page.  I 
> thought that this was because I was not setting the contentType, but I 
> have verified that this is being set to "text/html".  I have even 
> printed out what the contentType gets set to in catalina.out.
> 
> I have the following files :
> 
> HTMLFilter implements Filter
> HTMLFilterWrapper extends HttpServletResponseWrapper
> HTMLFilterOutputStream extends ServletOutputStream
> 
> any ideas ?

As far as I understand, you simply convert everything, including the tag
delimiters, so instead of "<body>" you get "&lt;body&gt;", and this is exactly
what your browser shows to you.  Try the "View source" function to check this.

Regards,

Andre.

-- 
=============================================================
Andre E. Bar'yudin
Home page:  http://www.cs.huji.ac.il/~baryudin/


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org