aspose file tools*
The moose likes Servlets and the fly likes GZIP Filter Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "GZIP Filter" Watch "GZIP Filter" New topic
Author

GZIP Filter

Shailesh Chandra
Ranch Hand

Joined: Aug 13, 2004
Posts: 1081

hi everyone !!!

I am not sure that this section is right place for my post

have any one used GZIPFiler in his applicationm, I am facing some problem in implementing same. There is an article about in at onjava.com

Two Servlet Filters Every Web Application Should Have
[ October 12, 2004: Message edited by: Shailesh Chandra ]

Gravitation cannot be held responsible for people falling in love ~ Albert Einstein
Graham Thorpe
Ranch Hand

Joined: Mar 25, 2002
Posts: 264
What type of problem are you facing using GZIP filter?
Do you want compress your jsp/html files from ur webapplication ?
Shailesh Chandra
Ranch Hand

Joined: Aug 13, 2004
Posts: 1081

Dear glkrr

I want to avail maximum benefit of it.

but when I add *.do ( in my struts application) for compression IE cause a
problem. First It try open like a file resource on server etc then prompt an error that coulnt open resource.
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17249
    
    6

Originally posted by Shailesh Chandra:
hi everyone !!!

I am not sure that this section is right place for my post

have any one used GZIPFiler in his applicationm, I am facing some problem in iplementing sqme. There is an article about in at onjava.com

Two Servlet Filters Every Web Application Should Have

[ October 08, 2004: Message edited by: Shailesh Chandra ]



Yeah, it really is the wrong forum for such a question. This forum is for Servlets questions only.

Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
Susanta Chatterjee
Ranch Hand

Joined: Aug 12, 2002
Posts: 102
Mark,

Which would be the correct forum for this question?

-Susanta
Graham Thorpe
Ranch Hand

Joined: Mar 25, 2002
Posts: 264
Try at web.xml

<filter>
<filter-name>GzipFilter</filter-name>
<filter-class>com.cj.gzipflt.GzipFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>GzipFilter</filter-name>
<url-pattern>/*.do</url-pattern>
</filter-mapping>
<filter>
<filter-name>GzipFilter</filter-name>
<filter-class>compression.Test</filter-class>
</filter>
<filter-mapping>
<filter-name>GzipFilter</filter-name>
<url-pattern>/*.do</url-pattern>
</filter-mapping>



for servlet



import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.util.zip.*;
import java.net.*;

public class DemoTest extends HttpServlet {

public void doPost(HttpServletRequest req, HttpServletResponse res) throws ServletException,IOException {
StringBuffer sb = new StringBuffer();
String s = "";
byte b;
System.out.println ("Entered DemoTEST");
res.setHeader("Content-Encoding","gzip");
res.setContentType ("text/html");
System.out.println("Enter");
try {
System.out.println ("Just after try");
URL url = new URL ("http://portalsit.ceemea.citibank.pl");
System.out.println ("one");
URLConnection urlc = url.openConnection();
System.out.println ("two");
DataInputStream dis = new DataInputStream (urlc.getInputStream());
while ((s=dis.readLine())!=null) {
sb.append(s);
System.out.println ("Data is :" + s);
}

GZIPOutputStream goz = new GZIPOutputStream(res.getOutputStream());
System.out.println("Enter1");

goz.write(sb.toString().getBytes());
System.out.println ("three");
goz.close();
}catch (Exception e) { System.out.println ("Exception is :" + e); }
}
}
Shailesh Chandra
Ranch Hand

Joined: Aug 13, 2004
Posts: 1081

Dear glkrr

my web.xml look like exactly same as you pasted here.
butmy application is creating problem only when there is *.do is added in web.xml but works fine with *.jpg,*.txt etc

even on some machine I get problem with these settnig seems there is some bug in Internet explorer

I found this article from microsoft for
Problem in IE
Graham Thorpe
Ranch Hand

Joined: Mar 25, 2002
Posts: 264
Did u test NetscapeNavigator?
Shailesh Chandra
Ranch Hand

Joined: Aug 13, 2004
Posts: 1081

actually I didn't try netscape because my application supports IE only.
but I will install netscape and will verify same .

since my application supports IE only so I am looking for a solution on IE

any ways thanks for your co-operation
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17249
    
    6

Well, with glkrr's reply, I'd say lets keep it here.

Mark
Sean Owen
author
Greenhorn

Joined: Nov 08, 2004
Posts: 21
I believe GZipFilter has a bug -- if the app server applies it twice to a single request, the response gets mangled since it is compressed twice. This can easily happen in a Struts application.

Try this open-source compression filter -- written by yours truly! It does not face this problem, so it may work correctly for you. It was also written to be much faster than GZipFilter and support more compression algorithms. I hope it helps.

PJL Compressing Filter
http://sourceforge.net/projects/pjl-comp-filter/
Shailesh Chandra
Ranch Hand

Joined: Aug 13, 2004
Posts: 1081

thanks Sean Owen !!!

I will give it a try !!!
Jean-Francois Samson
Greenhorn

Joined: Sep 22, 2009
Posts: 2



I gave it a try and it work like a charm. Thanks Sean!!!

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: GZIP Filter
 
Similar Threads
some API related doubt.
Have text editor need to add find funct
Dirty but Interesting
"package does not exist" message in servlet
reading returned datas from the url