File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes Not Compress PDF - using Sean Owen's Compression Filter Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Not Compress PDF - using Sean Owen Watch "Not Compress PDF - using Sean Owen New topic
Author

Not Compress PDF - using Sean Owen's Compression Filter

Sam Gehouse
Ranch Hand

Joined: Jul 21, 2003
Posts: 281
I am using Sean Owen's Compression Filter (http://sourceforge.net/projects/pjl-comp-filter/).

Is there an easy way NOT to compress the returned bytes, if the page returned is of type pdf? I cannot think of any entry in web.xml that will make it happen. The only approach I can think of is modifying the code of Sean Owen.
I can think of 2 ways:
1) Putting relevant packages in url-pattern in web.xml and I do not want to do it.
2) Modify Sean Owne's code so that it does not compress the result if the content type is of type pdf.
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 29255
    
140

Sam,
I can think of a third alternative: wrap the filter in one of your own and call your filter.

This new filter can check the extension. If it's not PDF, call Sean's filter.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Sean Owen
author
Greenhorn

Joined: Nov 08, 2004
Posts: 21
This is Sean Owen -- yes, beginning in version 1.3 of the filter, you can include or exclude certain content types from compression.

For example, to only compress HTML and XML, you can add configure the filter with this parameter in web.xml:

<init-param>
<param-name>includeContentTypes</param-name>
<param-value>text/html,text/xml</param-value>
</init-param>

Other content types will not be compressed. Alternatively, to compress everything except PDFs, you can use this parameter:

<init-param>
<param-name>excludeContentTypes</param-name>
<param-value>application/pdf</param-value>
</init-param>

You can't specify both at once though.

You can find javadocs here, and the latest version for download here. Please post messages there if you have any other questions or problems. Thanks!
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 29255
    
140

Sean,
The "here" doesn't appear to be a link. Could you try reposting that part?
Sean Owen
author
Greenhorn

Joined: Nov 08, 2004
Posts: 21
Oops!

Javadoc is at:
http://pjl-comp-filter.sourceforge.net/
Main page and download link are at:
http://sourceforge.net/projects/pjl-comp-filter/
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Not Compress PDF - using Sean Owen's Compression Filter
 
Similar Threads
Problem with *.do for Compression Filter using Struts
Yes, Sean Owen's Compression Filter works with /*
Image compression and decompression
Problem with Jayson Falkner's (onJava) Compression Filter
Servlet Filters with struts