This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Servlets and the fly likes regarding Http response header and response commited Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "regarding Http response header and response commited" Watch "regarding Http response header and response commited" New topic
Author

regarding Http response header and response commited

Brij Garg
Ranch Hand

Joined: Apr 29, 2008
Posts: 234
HTTP response consists of the status line, one or
more headers, a blank line, and the actual document, in that order

and

In HTTP version 2.2 with buffering enabled, you can
set headers until the buffer fills up and is actually sent to the client.

Keep these two point in mind,
my code is


In this code I am setting response header after response has been committed.Therefore this code should give IllegalStateException.

But i am getting output as "garg".

Need your comments on my understanding of this concept.
Thanks
[ August 21, 2008: Message edited by: Bear Bibeault ]
David O'Meara
Rancher

Joined: Mar 06, 2001
Posts: 13459

You're assumption is that the setContentType method will throw the Exception if the reponse is already commited, but the API says otherwise (namely)

Sets the content type of the response being sent to the client, if the response has not been committed yet.


Therefore the content type just gets missed, but no error is reported.
Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 41180
    
  45
By the way, there is no "HTTP 2.2"; the latest HTTP version is 1.1. Do you mean Servlet API version? If so, that's been obsolete for many years; we're at 2.5 now.
[ August 21, 2008: Message edited by: Ulf Dittmer ]

Ping & DNS - my free Android networking tools app
 
 
subject: regarding Http response header and response commited
 
Similar Threads
Servlet using SAAJ and HTTP Authorization Header
Basic Doubts in Header
Servlet using SAAJ and HTTP Authorization Header
sending email in servlet
modify the HTTP Header with a Filter