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 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 EJB 3 in Action this week in the EJB and other Java EE Technologies 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: 39547
    
  27
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 - updated with new look and Ping home screen widget
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: regarding Http response header and response commited
 
Similar Threads
Basic Doubts in Header
Servlet using SAAJ and HTTP Authorization Header
Servlet using SAAJ and HTTP Authorization Header
sending email in servlet
modify the HTTP Header with a Filter