aspose file tools*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Compression Filter Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Compression Filter" Watch "Compression Filter" New topic
Author

Compression Filter

Adolfo Eloy
Ranch Hand

Joined: Mar 21, 2009
Posts: 146

Hi all.

I'm studying chapter 13 from HF Servlets and JSP and I'm trouble with the Compression Filter example.
I've written all the code for this example (regarding the Errata for HF Servlets And JSP).

When requesting the most pages (either via servlet's URL pattern or directly JSP) I got no problems.
But when I try to call a specific Servlet all I get on the browser is a blank page.

This is the code of my Servlet:



Did anybody here already see this kind of problem?
Any ideas?

Thanks in advance.


Adolfo Eloy
Software Developer
OCPJP 6
Frits Walraven
Creator of Enthuware JWS+ V6
Bartender

Joined: Apr 07, 2010
Posts: 1696
    
  25

Hi Adolfo,

Did you try adding the HTML codes in your Servlet, like this:
If that doesn't work, please post your web.xml and the URL you are using to access the Servlet.

Regards,
Frits
Adolfo Eloy
Ranch Hand

Joined: Mar 21, 2009
Posts: 146

Hi Frits. Thanks for replying. I've tried what you post, but no success...
Instead of posting my web.xml, I've change the code to use Servlet 3.0's annotations to ease this post, ok?

This is a bit modified example of Compression filter available at Head First Servlet & JSP.

My servlet code:



This is the code of the filter:


Compression response wrapper:



and gzip servlet output stream wrapper:



Thanks in advance.
Frits Walraven
Creator of Enthuware JWS+ V6
Bartender

Joined: Apr 07, 2010
Posts: 1696
    
  25

If you uncomment the following line (se debugging tip page 723)
You will see that the browser gets zipped data.

Regards,
Frits
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Compression Filter