This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread for details.
The moose likes Servlets and the fly likes GZIP Utility Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Servlets
Bookmark "GZIP Utility" Watch "GZIP Utility" New topic
Author

GZIP Utility

Sagar Sharma
Ranch Hand

Joined: Aug 31, 2000
Posts: 92
Do i need to code extra except setting of the Accept-Encoding Header to send HTML files in a GZIP format??

thanks in advance

sagar

Bob Moranski
Ranch Hand

Joined: Nov 22, 2000
Posts: 177
You also need GZIPOutputStream. You can get it by
OutputStream out = new GZIPOutputStream(res.getOutputStream());
Then you can send it with ServletUtils class in Oreilly's servlet com package from www.servlets.com.
try{
ServletUtils.returnFile(file, out);
//file being the path to the specified file
}
catch(FileNotFoundException e){
throw new ServletException("No such file");
}
catch(IOException e){
throw new ServletException("Problem sending file...");
}
 
Have you checked out Aspose?
 
subject: GZIP Utility
 
It's not a secret anymore!