I did finally get my caching filter to work by following the same logic included in the GZip filter included in Tomcat 4.1.18. It works VERY well :-) Hopefully we can resurrect the Common's Cache project that includes filters and taglibs?
-Jacob | -----Original Message----- | From: Cox, Charlie [mailto:[EMAIL PROTECTED]] | Sent: Monday, January 27, 2003 7:48 AM | To: 'Tomcat Users List' | Cc: 'Jacob Kjome' | Subject: RE: [Tomcat 4.1] Caching JSP Output via Filter PLZ HELP!! | | see the thread titled: | RE: Tomcat 4.1.18/19 - How to activate gzip support? | http://www.mail-archive.com/[email protected]/msg82477.html | | and read the associated links about a similar problem (filter works for | static content, not for dynamic). | | Charlie | | | > -----Original Message----- | > From: Jacob Hookom [mailto:[EMAIL PROTECTED]] | > Sent: Saturday, January 25, 2003 12:21 PM | > To: 'Tomcat Users List' | > Subject: RE: [Tomcat 4.1] Caching JSP Output via Filter PLZ HELP!! | > | > | > I did something very similar to what you have here, but I did a | > DualServletOutputStream where if the printwriter was | > requested from the | > HttpServletResponseWrapper, I would return a new PrintWriter | > that wrapped my | > DualServletOutputStream. The dual output stream contains the | > super.getOutputStream() (the actual response output) and the | > BufferedOutputStream that is used to getByteArray() and cache it. | > | > It's very strange though because again, HTML files are | > successfully cached | > and I can even look at the serialized content on the file | > system, but 0 | > bytes are written from JSP requests, even though I can see in my Log4j | > output that indeed the getWriter() method was called on my | > HttpServletResponseWrapper. | > | > Best Regards, | > Jacob Hookom | > | > -----Original Message----- | > From: li pan [mailto:[EMAIL PROTECTED]] | > Sent: Friday, January 24, 2003 11:01 PM | > To: [EMAIL PROTECTED] | > Subject: RE: [Tomcat 4.1] Caching JSP Output via Filter PLZ HELP!! | > | > | > Hello Jacob | > I have successfully implemented this idea. I guess you mean | > that get the | > writer of JSP, and replace the writer with another one which | > will cache the | > jsp results as well as output them to the original writer? | > Yes, it works. | > I didn't use a filter, I simply hacked tomcat, so that my | > cache facility | > can be used by any web applications without modifying source | > codes of them. | > But I didn't get trouble by getWriter(), I guess maybe : | > 1 before you get the writer from the filter, tomcat has already done | > something to the writer? I get it right after the JSP | > instance is built. | > 2 tomcat does not allow you to change the writer of a | > response while it is | > in the filter chain? I also replace the response with my own | > wrapper, so I | > don't change it. | > | > Here is my buffered writer: | > | > package servercache; | > import java.io.PrintWriter; | > import java.nio.CharBuffer; | > public class BufferedPrintWriter | > extends PrintWriter { | > | > private PrintWriter writer; | > private CharBuffer buffer = CharBuffer.allocate(1024); | > | > public BufferedPrintWriter(PrintWriter writer) { | > super(writer); //doesnot make any sense. | > this.writer = writer; | > } | > | > public void write(char[] buf, int offset, int count) { | > writer.write(buf, offset, count); | > buffer.put(buf, offset, count); | > } | > | > public void write(String str) { | > writer.write(str); | > buffer.put(str); | > } | > | > public void print(String str) { | > writer.print(str); | > | > if (str == null) { | > buffer.put("null"); | > } else { | > buffer.put(str); | > } | > } | > | > public void println(String str) { | > writer.println(str); | > buffer.put(str); | > buffer.put("\n"); | > } | > | > public CharBuffer getBuffer() { | > | > return buffer; | > } | > } | > | > and here is how it is created: | > | > writer = new BufferedPrintWriter(response.getWriter()); | > | > | > | > _________________________________________________________________ | > �����������ѽ��н�������ʹ�� MSN Messenger: http://messenger.msn.com/cn | > | > | > -- | > To unsubscribe, e-mail: | > <mailto:[EMAIL PROTECTED]> | > For additional commands, e-mail: | > <mailto:[EMAIL PROTECTED]> | > | > | > -- | > To unsubscribe, e-mail: | > <mailto:[EMAIL PROTECTED]> | > For additional commands, e-mail: | > <mailto:[EMAIL PROTECTED]> | > | | -- | To unsubscribe, e-mail: <mailto:tomcat-user- | [EMAIL PROTECTED]> | For additional commands, e-mail: <mailto:tomcat-user- | [EMAIL PROTECTED]> -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
