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 Content-Encoding Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Content-Encoding" Watch "Content-Encoding" New topic
Author

Content-Encoding

Cameron Park
Ranch Hand

Joined: Apr 06, 2001
Posts: 371
Hi, I am unclear about the header "Content-Encoding" and what its corresponding value does. When we setHeader to be "Content-Encoding", "x-gzip", does it send out the requested file in the zip format?
What is the differences between "x-gzip" and "gzip"?
Peter den Haan
author
Ranch Hand

Joined: Apr 20, 2000
Posts: 3252
Originally posted by Cameron Park:
Hi, I am unclear about the header "Content-Encoding" and what its corresponding value does. When we setHeader to be "Content-Encoding", "x-gzip", does it send out the requested file in the zip format?

No. These MIME types are merely a label telling the browser what type of content you're sending. It is up to you to ensure that what you are sending actually matches the encoding you set.
If you'd like to see this in action then just do this little experiment. Write a one-line JSP

and check it out with a browser. Now try setting set the content type:

and check it out again. The second time round, you're telling the browser that you are going to send plain text. As a consequence, it makes no attempt interpreting the HTML tags and will show your HTML source.
What is the differences between "x-gzip" and "gzip"?

The difference is that all "x-" types are unregistered and experimental. I guess that support for "x-gzip" was retained even after proper registration of the "gzip" type and don't think there is any difference in practice. MIME types are governed by the Internet Engineering Task Force (IETF) RFCs. For a thorough overview, look at RFC 2045-2049.
- Peter
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Content-Encoding