Hi.
This is not really a Tomcat question, rather something one should be
able to do with Tomcat, but I-don't-know-how kind of thing.
It was inspired by this servlet :
http://www.javaside.com/u_zipservlet.html
The question is :
Suppose that to gain space on my Tomcat server and to speed up content
delivery, I have a whole bunch of files in one of my Tomcat contexts,
which have been pre-zipped.
That is, I have for example a.txt, b.txt, c.txt etc... but all these
huge text files have already been pre-zipped, and they are really on my
server as
(catalina_base)/webapps/mywebapp/
a.txt.zip
b.txt.zip
c.txt.zip
etc...
Now I would like the user to be able to request the URL
http://hostname/mywebapp/a.txt
and obtain this file, as a text, displayed in the browser window.
Of course I do not want Tomcat to retrieve the file a.zip, unzip it, and
send it back unzipped as a.txt. I want it to remain zipped during
transmission, to use less bandwidth.
And I also do not want to leave my files on disk as a.txt, b.txt, etc..
and ask Tomcat to compress them on-the-fly just before sending them to
the browser. The files are already compressed, so that would be a waste
of CPU cycles.
Thus I want my Tomcat webapp to
- receive a request for /a.txt
- see that there is aready, on disk, a file a.txt.zip
- consequently, read a.txt.zip, and send this "as is" back to the
browser, but telling the browser that this has only be zipped for
transmission, but that it is really a.txt, and ask the browser to unzip
it and display it as text.
(If it makes it easier to conceive the difference or benefit, you can
also think that instead of text files, these are originally very large
PDF files (say a.pdf), which have been zipped (as a.pdf.zip), but which
I want to display as PDF in the browser (as a.pdf))
How would you do that ?
I can think of creating a special servlet that would do that, by playing
with the Content-transfer-encoding header.
But considering that the default servlet must be already doing more than
that (when it actually compresses content before returning it), and is
probably much better written and optimised than what I could come up
with myself, isn't there a smarter way to do this without writing a
special servlet to do it ?
You see, we perl programmers are lazy; and you Java/Tomcat guys are
smart. There should be some synergy there.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tomcat.apache.org
For additional commands, e-mail: users-h...@tomcat.apache.org