File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JSP and the fly likes Using gzip in jsp files Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "Using gzip in jsp files" Watch "Using gzip in jsp files" New topic

Using gzip in jsp files

Vinay Singh
Ranch Hand

Joined: Dec 15, 2004
Posts: 174
I am trying to speed up the performance of my application . I am using firebug and Yslow has recommended some techniques.
One of the issues we have is that there are around 24 java script files which are loaded every time. That mean 24 requests.
We cannot club them into one from maintainability perspective .
So the other option is compress these files using gzip. I downloaded the utility from gzip site

I am can compress the file using gzip and it is transmitted successfully.

The problem arises when app tries to use validation inside these files. The java script code is not executed.
I think the reason could be that the browser is not able to decompress the file

This was original code in jsp

<script type="text/javascript" src="<c:url value="/scripts/lib/validate.js"/>"></script>

the .js has been replaced with .js.gz
<script type="text/javascript" src="<c:url value="/scripts/lib/validate.js.gz"/>"></script>

I am not sure if we would have to manually gzip the files or we enable some flag in server which serves the files as gzip files from server.

Any help is appreciated

Technical quiz and interview questions   SCJP 6 mock practice test
Bear Bibeault
Author and ninkuma

Joined: Jan 10, 2002
Posts: 63844

Please take the time to choose the correct forum for your posts. This forum is for questions on HTML.

For more information, please read this.

This post has been moved to a more appropriate forum.

[Asking smart questions] [About Bear] [Books by Bear]
David Newton

Joined: Sep 29, 2008
Posts: 12617

That's not how gzipping from the server works AFAIK--you're just sending a binary file without providing the client any way of knowing what it's receiving.

The canonical way to do this is to use a gzip filter, of which there are an abundance.
I agree. Here's the link:
subject: Using gzip in jsp files
It's not a secret anymore!