jQuery in Action, 3rd edition
The moose likes Tomcat and the fly likes Compression in Tomcat5/Apache2 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of OCA Java SE 8 Programmer I Study Guide this week in the OCAJP 8 forum!
JavaRanch » Java Forums » Products » Tomcat
Bookmark "Compression in Tomcat5/Apache2" Watch "Compression in Tomcat5/Apache2" New topic

Compression in Tomcat5/Apache2

cs gthri

Joined: Jan 28, 2005
Posts: 2
Can someone pl clear these doubts..
(1) What is GZIP,mod_gzip and mod_deflate? and how are they different?
(2) How can you enable mod_gzip in Apache 2.x? I find that only mod_deflate is available in httpd.conf file.
(3) Instead of coding JSP for compression, why cant you enable the builtin compression facility already available with servlet engine (eg.Tomcat 5.0.28)?Is there any difference?
(4) In fact, why cant we simply enable the mod_deflate compression facility available in the web server itself (eg.Apache2.0.52)?,instead of coding the JSP or enabling the one in the servlet engine. Wont the web server then compress all the output?(HTML's,JSP's and serialised Object's)?.
(4)Can you compress the serialised object sent from the servlet to applet?how can you do that? Do you need to write additional code in servlet for compression or just enabling mod_deflate would be enough?(would appreciate some code)
(5) What is the correct method of adding a new web application in Tomcat 5.0.28? I am using Apache2.0.52-mod_jk2-Tomcat5.0,28.What are the modification actually required in conf/server.xml and WEB-INF/web.xml files? Beacuse, you have mentioned the need to add the line, <Context path=......reloadable="true"/> within <Host></Host> in conf/server.xml.This line is not there initially.You have to manually add it and found that without this line, i have to restart Tomcat every time i modified my servlet,for the new code to take effect. Is this correct and is it necessary?

Mark Spritzler

Joined: Feb 05, 2001
Posts: 17276

Moving this thread to the more appropriate Apache/Tomcat forum.


Perfect World Programming, LLC - iOS Apps
How to Ask Questions the Smart Way FAQ
Mike Curwen
Ranch Hand

Joined: Feb 20, 2001
Posts: 3695

1) gzip is the algorithm used to do the compression. mod_gzip and mod_deflate are two different apache modules that use gzip to compress server responses. gzip is 3rd party, mod_deflate is put out by apache
Info found by google:

2) mod_deflate is available because it's from apache and *probably* comes with the standard distribution. mod_gzip you'd have to download.
Info found by typing mod_deflate into search box on:

3) no reason you can't. That's your choice. This would be most useful if you are running Tomcat standalone, and using apache compression is simply unavailable. As for a difference between "coding your own in a JSP" and using the container's "built-in".... when you code your own, you can convince yourself you're doing a better job.
found by google:

4) again, no reason. Is that what you want to do? Web servers (and the Tomcat HTTP connector) will compress whatever MIME types you tell it to compress.

4#2) Yes. Any number of ways. Let tomcat do it, let the webserver do it, or programmatically. The applet will of course, need to un-compress the serialized object itself. For web pages, it's easy to add compression, because all modern browsers can un-compress the gzip'd pages and images and style sheets. Your applet will need similar help (probably).
stuff found by google:
hmm... looks like what you're wanting to know is possible, since it's someone else's homework:

5) http://jakarta.apache.org/tomcat/tomcat-5.0-doc/appdev/deployment.html

In conf/server.xml is one place you can specify your new application, but not the only one (though it's the oldest and most understood).

modification to WEB-INF/web.xml ? If you're talking about the one supplied by Tomcat, none. If you're talking about the one in your web application... then it needs to exist, and lists all the servlets, filters, etc, etc, to be used in your app.

Adding that line is "correct", and it's certainly necessary if you don't want to restart Tomcat every time you change something.
Eduardo Bapner

Joined: Jun 15, 2010
Posts: 2
Hi everyone. AS I see you have a very clear idea of these kind of scenarios, I'm going to ask you about my issue.

I have 2 groups of servers (3 jboss for one client and 2 jboss for other client). Every jboss has been configured with "compressionMinSize and compressableMimeType. Each group is a cluster balanced from other system acting as a mod-jk proxy and load balancer.

When i acces directly to the jboss on one system (without going through the proxy/loadbalancer) the responses are compressede, but when i access through the proxy, they are uncompressed.

¿Is there any way of making my proxy "transparent" so responses keep compressed?

I don´t want the apache to perform the comrpession as is a shared equipment that can be compromised by the load introduced using compression.

Thanks in advance for your answers.
I agree. Here's the link: http://aspose.com/file-tools
subject: Compression in Tomcat5/Apache2
It's not a secret anymore!