aspose file tools*
The moose likes Tomcat and the fly likes Tomcat's  CompressionFilter + ExampleFilter code Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Products » Tomcat
Bookmark "Tomcat Watch "Tomcat New topic
Author

Tomcat's CompressionFilter + ExampleFilter code

Joseph Sweet
Ranch Hand

Joined: Jan 29, 2005
Posts: 327
Hello friends,

Where can I find the code for these filters on the web???

Have searched googgle but no help.


We must know, we will know. -- David Hilbert
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Originally posted by Joseph Sweet:
Have searched googgle but no help.


You couldn't have searched for long.


http://www.google.com/search?hl=en&q=SERVLET+FILTER+TUTORIAL+GZIP&btnG=Google+Search


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
Joseph Sweet
Ranch Hand

Joined: Jan 29, 2005
Posts: 327
Thank you
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Glad to help.

You do know that Tomcat has built in compression capabilities, right?
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

http://jakarta.apache.org/tomcat/tomcat-5.5-doc/config/http.html
Joseph Sweet
Ranch Hand

Joined: Jan 29, 2005
Posts: 327
Thank you again.

I did not know of that.
I will have to read that refernce.
It is good to know.
:roll:

Actually, I am trying to understand filters, and wanted to see the code they wer eusing in some articles.
Joseph Sweet
Ranch Hand

Joined: Jan 29, 2005
Posts: 327
What is actually a stream? Particularly a ServletOutputStream?


In the GZIPResponseWrapper extends HttpServletResponseWrapper, there is:







Why do I have to define (override) that method? Why do they have a problem if the writer was initialized?






Okay PrintWriter I know. that's the class that lets me write the servlet's output to the HttpServletResponse.

Why does it have a problem if the stream is already initialized?

Also, if HttpServletResponse is an interface, how can we define an instance of it???
[ April 27, 2005: Message edited by: Joseph Sweet ]
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

You may want to consider starting a new thread in the servlets forum as this one attracts mostly people interested in configuring and debugging Tomcat..



Okay PrintWriter I know. that's the class that lets me write the servlet's output to the HttpServletResponse.
Why does it have a problem if the stream is already initialized?
Picture a servlet trying to return 2 streams OR
picture two pieces of code trying to write to the same stream.
That codes insures that there is only one and that it's clean.


Also, if HttpServletResponse is an interface, how can we define an instance of it???
The javax.servlet.http package provides the HttpServletResponseWrapper which you can extend and then, override whatever methods you need to in order to accomplish your goals.
http://java.sun.com/j2ee/sdk_1.3/techdocs/api/javax/servlet/http/HttpServletResponseWrapper.html
[ April 27, 2005: Message edited by: Ben Souther ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Tomcat's CompressionFilter + ExampleFilter code