You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by BILODEAU Guillaume SOFRECOM <gu...@sofrecom.com> on 2004/02/05 14:59:02 UTC

REPOST: GZipping response with Servlet 2.2 / Struts 1.0

Hi everyone,

I have read the following reply (rather old) in the archives:

>In servlet 2.2 environments, you basically won't be able to do this.
But
>in servlet 2.3 environments, you can create a Filter to do the
compression
>for you, on output from either servlets or JSP pages.

This was in response to a question about adding GZip compression to a
JSP in a Struts environment.  I have tried doing a similar thing by
extending the ActionServlet class and wrapping the original response in
a GZip-compressed response, but without any success: I constantly end up
receiving a download dialog on my browser (as if I were sending a zipped
file) or getting ClassCastExceptions (with IBM WebSphere classes being
expected).  I suspect the forward mechanism is the cause to all that.

Can you confirm that it is impossible to add such support for
compression even by extending the ActionServlet?  Would there be any
other mechanism to compress the response sent to the client?  Any
pointers on the web?  I am using the servlet 2.2 API on WebSphere 4.0.3.

Thanks a lot,
Guillaume



---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


RE: REPOST: GZipping response with Servlet 2.2 / Struts 1.0

Posted by Nirmal Davis V <ni...@aztec.soft.net>.
Hi,

Have u set the http headers properly? If we don't set the headers properly
browser will throw up the dialog box saying save/open it.
Here is what I tried and what I found working on Tomcat 4.1.29, IE 6.0

Inside doGet() or doPost() -

		String acceptEncodingHeaderStr = request.getHeader("Accept-Encoding");
		System.out.println("acceptEncodingHeaderStr : "+acceptEncodingHeaderStr);

		boolean supportGZip = false;
		if(acceptEncodingHeaderStr != null) {
			if( (acceptEncodingHeaderStr.toLowerCase().indexOf("gzip")) > -1 )
				supportGZip = true;
		}

		if(supportGZip) {
			//Sets the proper headers
			response.setHeader("Content-Encoding", "gzip");
			response.setHeader("Content-Type","text/html");

			GZIPOutputStream gzos = new GZIPOutputStream(response.getOutputStream());
			StringBuffer sb = new StringBuffer();
			sb.append("This is thru zipped output stream");
			gzos.write(sb.toString().getBytes());
			gzos.close();
		}

Thanks & Regards,
Nirmal

-----Original Message-----
From: BILODEAU Guillaume SOFRECOM [mailto:guillaume.bilodeau@sofrecom.com]
Sent: Thursday, February 05, 2004 8:55 PM
To: Struts Users Mailing List
Subject: Re: REPOST: GZipping response with Servlet 2.2 / Struts 1.0

GZip compression on the web server using mod_gzip seemed like a suitable
solution to my problem, but unfortunately it is not usable in our
environment:
the web server is shared by multiple applications and such a configuration
modification would require the approval of all other teams (which would be
incredibly lengthy, painful, and would probably end up being rejected).

Compression definitely has to be done at a code level.  Too bad we don't
have
servlet filter support... :(

Thanks,
GB


Martin Gainty a écrit :

> Have you posted this to the GZIP Discussion list at
mod_gzip@lists.over.net
> Regards,
> -Martin
> ----- Original Message -----
> From: "BILODEAU Guillaume SOFRECOM" <gu...@sofrecom.com>
> To: <st...@jakarta.apache.org>
> Sent: Thursday, February 05, 2004 8:59 AM
> Subject: REPOST: GZipping response with Servlet 2.2 / Struts 1.0
>
> > Hi everyone,
> >
> > I have read the following reply (rather old) in the archives:
> >
> > >In servlet 2.2 environments, you basically won't be able to do this.
> > But
> > >in servlet 2.3 environments, you can create a Filter to do the
> > compression
> > >for you, on output from either servlets or JSP pages.
> >
> > This was in response to a question about adding GZip compression to a
> > JSP in a Struts environment.  I have tried doing a similar thing by
> > extending the ActionServlet class and wrapping the original response in
> > a GZip-compressed response, but without any success: I constantly end up
> > receiving a download dialog on my browser (as if I were sending a zipped
> > file) or getting ClassCastExceptions (with IBM WebSphere classes being
> > expected).  I suspect the forward mechanism is the cause to all that.
> >
> > Can you confirm that it is impossible to add such support for
> > compression even by extending the ActionServlet?  Would there be any
> > other mechanism to compress the response sent to the client?  Any
> > pointers on the web?  I am using the servlet 2.2 API on WebSphere 4.0.3.
> >
> > Thanks a lot,
> > Guillaume
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: struts-user-help@jakarta.apache.org
> >
> >


---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org

---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


Re: REPOST: GZipping response with Servlet 2.2 / Struts 1.0

Posted by BILODEAU Guillaume SOFRECOM <gu...@sofrecom.com>.
GZip compression on the web server using mod_gzip seemed like a suitable
solution to my problem, but unfortunately it is not usable in our environment:
the web server is shared by multiple applications and such a configuration
modification would require the approval of all other teams (which would be
incredibly lengthy, painful, and would probably end up being rejected).

Compression definitely has to be done at a code level.  Too bad we don't have
servlet filter support... :(

Thanks,
GB


Martin Gainty a écrit :

> Have you posted this to the GZIP Discussion list at mod_gzip@lists.over.net
> Regards,
> -Martin
> ----- Original Message -----
> From: "BILODEAU Guillaume SOFRECOM" <gu...@sofrecom.com>
> To: <st...@jakarta.apache.org>
> Sent: Thursday, February 05, 2004 8:59 AM
> Subject: REPOST: GZipping response with Servlet 2.2 / Struts 1.0
>
> > Hi everyone,
> >
> > I have read the following reply (rather old) in the archives:
> >
> > >In servlet 2.2 environments, you basically won't be able to do this.
> > But
> > >in servlet 2.3 environments, you can create a Filter to do the
> > compression
> > >for you, on output from either servlets or JSP pages.
> >
> > This was in response to a question about adding GZip compression to a
> > JSP in a Struts environment.  I have tried doing a similar thing by
> > extending the ActionServlet class and wrapping the original response in
> > a GZip-compressed response, but without any success: I constantly end up
> > receiving a download dialog on my browser (as if I were sending a zipped
> > file) or getting ClassCastExceptions (with IBM WebSphere classes being
> > expected).  I suspect the forward mechanism is the cause to all that.
> >
> > Can you confirm that it is impossible to add such support for
> > compression even by extending the ActionServlet?  Would there be any
> > other mechanism to compress the response sent to the client?  Any
> > pointers on the web?  I am using the servlet 2.2 API on WebSphere 4.0.3.
> >
> > Thanks a lot,
> > Guillaume
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: struts-user-help@jakarta.apache.org
> >
> >


---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


Re: REPOST: GZipping response with Servlet 2.2 / Struts 1.0

Posted by Martin Gainty <mg...@hotmail.com>.
Have you posted this to the GZIP Discussion list at mod_gzip@lists.over.net
Regards,
-Martin
----- Original Message ----- 
From: "BILODEAU Guillaume SOFRECOM" <gu...@sofrecom.com>
To: <st...@jakarta.apache.org>
Sent: Thursday, February 05, 2004 8:59 AM
Subject: REPOST: GZipping response with Servlet 2.2 / Struts 1.0


> Hi everyone,
> 
> I have read the following reply (rather old) in the archives:
> 
> >In servlet 2.2 environments, you basically won't be able to do this.
> But
> >in servlet 2.3 environments, you can create a Filter to do the
> compression
> >for you, on output from either servlets or JSP pages.
> 
> This was in response to a question about adding GZip compression to a
> JSP in a Struts environment.  I have tried doing a similar thing by
> extending the ActionServlet class and wrapping the original response in
> a GZip-compressed response, but without any success: I constantly end up
> receiving a download dialog on my browser (as if I were sending a zipped
> file) or getting ClassCastExceptions (with IBM WebSphere classes being
> expected).  I suspect the forward mechanism is the cause to all that.
> 
> Can you confirm that it is impossible to add such support for
> compression even by extending the ActionServlet?  Would there be any
> other mechanism to compress the response sent to the client?  Any
> pointers on the web?  I am using the servlet 2.2 API on WebSphere 4.0.3.
> 
> Thanks a lot,
> Guillaume
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: struts-user-help@jakarta.apache.org
> 
> 

---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org


Re: REPOST: GZipping response with Servlet 2.2 / Struts 1.0

Posted by Franck Lefebure <fl...@orangecaraibe.com>.
Le Thursday, February 05, 2004 9:59 AM,
BILODEAU Guillaume SOFRECOM <gu...@sofrecom.com> m'a, d'une
plume avisee, ecrit:

> Hi everyone,
>
> Would there be any other mechanism to compress the response sent to the
client?

Hi,

My application server (Jrun) is interfaced with Apache,
And I use mod_gzip in Apache. configuration is a litthe tricky
but it works very well

Bye


-- 

Franck Lefebure


---------------------------------------------------------------------
To unsubscribe, e-mail: struts-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-user-help@jakarta.apache.org