Howdy, I saw the original message but never got around to commenting on it, as:
- I wrote a compression filter from scratch just to try it out, right when servler 2.3 came out, and tomcat 4.0.4 had no problems with that filter, all worked fine. I tried this with JSPs, servlets, and static content. - I've been using the tomcat supplied compression filter since 4.1.10 without problems. I only use this one for servlets, as I don't have much JSP and all my static content is very small (tiny images). That said, if you really like your own filter, perhaps you can post the source for the two different response wrappers, and we can start there in looking for bugs? Yoav Shapira Millennium ChemInformatics >-----Original Message----- >From: Jacob Kjome [mailto:[EMAIL PROTECTED] >Sent: Friday, March 14, 2003 9:27 AM >To: Tomcat Users List >Subject: Re: inconsistencies in Tomcat handling servlet filters... > > > >No one has any opinions or comments on this? I can't believe no one else >has run into this problem. > >Jake > >At 04:46 PM 3/13/2003 -0600, you wrote: > >>I've mentioned this issue before regarding a GZIPFilter that wasn't >>working under Tomcat except for static file content (not working for JSP's >>and servlets). However, I didn't get much response to that and it was >>probably due to the complexity of the problem. Well, here is a simplied >>approach to the issue.... >> >>I am seeing vastly differing behavior for this filter depending on whether >>it is filtering static content or JSP's and servlets and it seems to me >>that this differing behavior must be a bug in Tomcat. Can someone >>validate whether or not this is a Tomcat bug? >> >>Here is the code in question. Note that I have some comments in the code >>that explain what works, what doesn't so read that to get an idea of what >>I am talking about. I have attached all the code in question, but this is >>the meat of it (based on the tutorial at >>http://www.orionserver.com/tutorials/filters/3.html ). >> >>public class PrePostFilter extends GenericFilter { >> >> public void doFilter(final ServletRequest request, >> final ServletResponse response, >> FilterChain chain) >> throws IOException, ServletException { >> >> PrintWriter out = response.getWriter(); >> >> //works as expected for static html, but not for JSP's where >> original content is discarded >> //GenericResponseWrapper wrapper = new >> GenericResponseWrapper((HttpServletResponse) response); >> >> //works as expected for both static html and JSP's >> CharResponseWrapper wrapper = new >> CharResponseWrapper((HttpServletResponse) response); >> >> chain.doFilter(request, wrapper); >> String responseString = wrapper.toString(); >> responseString = "<HR>PRE<HR>" + responseString + "<HR>POST<HR>"; >> response.setContentLength(responseString.length()); >> out.write(responseString); >> >>/* >> //works as expected for JSP's, but not static html where >> everything but the "POST" data is written >> out.write("<HR>PRE<HR>"); >> CharResponseWrapper wrapper = new >> CharResponseWrapper((HttpServletResponse) response); >> chain.doFilter(request, wrapper); >> out.write(wrapper.toString()); >> out.write("<HR>POST<HR>"); >>*/ >> >> out.flush(); >> out.close(); >> } >> >>} >> >>Questions to answer... >> >>1. Why don't all 3 examples produce exactly the same output? It seems to >>me that they should. >>2. Why does using a response wrapper that uses a ByteArrayOutputStream >>(as in GenericResponseWrapper) not work with JSP's? The original data is >>always unavailable. >>3. Why do I have to use a PrintWriter when filtering JSP's? Why can't I >>use an OutputStream? Using an OutputStream gets me the same results as >#2. >> >>So, is there anything wrong with my code or is something just goofy in >Tomcat? >> >>Jake >> >> >>--------------------------------------------------------------------- >>To unsubscribe, e-mail: [EMAIL PROTECTED] >>For additional commands, e-mail: [EMAIL PROTECTED] This e-mail, including any attachments, is a confidential business communication, and may contain information that is confidential, proprietary and/or privileged. This e-mail is intended only for the individual(s) to whom it is addressed, and may not be saved, copied, printed, disclosed or used by anyone else. If you are not the(an) intended recipient, please immediately delete this e-mail from your computer system and notify the sender. Thank you. --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
