You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tomcat.apache.org by balachandra maddina <ch...@gmail.com> on 2009/06/11 10:22:36 UTC

Re: How to use a gzip javascript file in a webapp running under tomcat

Hi chris,

 Thx for the reply. just after posting the question i tried the same
steps and the files are getting gzip.

Thank you,
bala.

On 6/11/09, Christopher Schultz <ch...@christopherschultz.net> wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Bala,
>
> On 6/10/2009 8:37 AM, balachandra maddina wrote:
>> I'm wondering if its possible to refer [to] a javascript file something
>> like
>> <script ... src ='scriptfile.js.gz'> in a html page where the script file
>> is
>> located in one of the tomcat webapps?
>
> Sure, you can do that. It just won't do what you expect it to.
>
>> if not how to send a gzip javascript file to browser? any help would be
>> appreciated.
>
> Try enabling gzip compression in the <Connector>.
>
> http://tomcat.apache.org/tomcat-6.0-doc/config/http.html#Standard%20Implementation
>
> Look for the "compression" attribute. You'll probably have to change the
> compressablemimeType setting from the default to include text/css.
>
> I don't think there's a way to trick Tomcat into using a pre-compressed
> image of a file in this way.
>
> Alternatively, you could probably do something like the following:
> create a servlet that does nothing but serve a file off the disk (you
> might even extend the DefaultServlet). Make sure that your servlet reads
> your gzip'd CSS file and serves it without modification, except to add a
> "Content-Encoding" header.
>
> Remember to ensure that the client has "Accept-Encoding: gzip" set in
> the request headers... otherwise you will be serving a file that the
> browser claims it can't read.
>
> Good luck,
> - -chris
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.9 (MingW32)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
>
> iEYEARECAAYFAkowG2MACgkQ9CaO5/Lv0PC98ACgnQZ2/PKp5QgYsQJkTgPYGVep
> vKgAniqftK7UQndCyoax6Fb+pR3C+vwl
> =irZW
> -----END PGP SIGNATURE-----
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
For additional commands, e-mail: users-help@tomcat.apache.org