Win a copy of Murach's Python Programming this week in the Jython/Python forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Control of content encoding  RSS feed

 
D Rog
Ranch Hand
Posts: 472
Linux Objective C Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello fellows ranchers
If somebody visited Community One on last Monday, probably remember how important to compress response from servlet. I learnt that some containers support compression out of the box. However my question is about what control of that we have from servlet side? For example if I call

Will servlet container automatically apply this encoding for everything I put in stream taken as getServletOutputStream()?
If I need to encode myself, can somebody explain me why
response.setHeader("Content-Encoding", "deflate"); doesn't work with conjunction of DeflaterOutputStream. IE6/7 can't display page. However
response.setHeader("Content-Encoding", "gzip"); with GZIPOutputStream works like a charm?
 
Rahul Bhattacharjee
Ranch Hand
Posts: 2308
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think you have to do all the encoding stuff .In order the client to make use of the encoded data that you have sent , you set the content-type.
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Before using a particular compression method the server should check that the request header "Accept-Encoding" lists that compression method. Is that the case here? Maybe IE doesn't support deflate.
 
Deepak Bala
Bartender
Posts: 6663
5
Firefox Browser Linux MyEclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Ulf Dittmer:
Before using a particular compression method the server should check that the request header "Accept-Encoding" lists that compression method. Is that the case here? Maybe IE doesn't support deflate.


Yep that could be the problem. You must check if the encoding you choose is supported by the target browser. If it is required that all your servlets must compress the data use a filter and use the response wrapper 'out' to write your data.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!