• Post Reply Bookmark Topic Watch Topic
  • New Topic

Using response.setContentLength in a Web Application ?  RSS feed

 
Ravi Kiran Va
Ranch Hand
Posts: 2234
Eclipse IDE Firefox Browser Redhat
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello ,


How is this response.setContentLength is useful in a Web Application ?


Thanks


Kiran.
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13078
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Some applications will not work correctly if the content length is not set for graphic and binary resources.

I have seen this with PDF files requested by browsers.

Basically it is good practice to set content length if you can get it.

Bill
 
Ravi Kiran Va
Ranch Hand
Posts: 2234
Eclipse IDE Firefox Browser Redhat
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks william (especially getting a response on sunday)

Means you mean to say that this is useful when the server is returning the response to a client request ??

But what happens if i set this content Length or not set this content Length ? How this will effect my application ?
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As William said your application may not work if the content length isn't set.

What are you trying to ask?
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13078
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Affect your application..... let see

Because content length has to be set before any part of the response is sent, your design must provide a way to calculate the value early on. For example if your servlet dynamically creates an image, it will have to be entirely written to a file or an in-memory buffer first. This has some design and memory requirement implecations.

Not setting the content length may result in a service that works for certain browser and response lengths and not for others, resulting in mysterious bugs.

Bill
 
Ravi Kiran Va
Ranch Hand
Posts: 2234
Eclipse IDE Firefox Browser Redhat
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
THANK YOU WILLIAM .
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!