wood burning stoves 2.0*
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes Response Commited Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "Response Commited" Watch "Response Commited" New topic
Author

Response Commited

Hussam Odeh
Ranch Hand

Joined: Jul 03, 2007
Posts: 55
Dear all,

can anyone tell me what exactly are the situations that makes the response considered to be commited?


SCJA 1.0: 98%, SCJP 5.0: 97%, SCWCD 5.0: 100%
Nicholas Jordan
Ranch Hand

Joined: Sep 17, 2006
Posts: 1282
Commited is database programming, Web Component Certification has to do with Servlet and so on. That is at least what I found in a three minute effort. What is Response Commited in Sun Certified Web Component Developer for the Java Platform, Enterprise Edition 5 (CX-310-083)?

I am sure I understand your question, you are asking when the activity of the Web Component is complete. I am responding that Response Commited is database programming.
Hussam Odeh
Ranch Hand

Joined: Jul 03, 2007
Posts: 55
Originally posted by Nicholas Jordan:
Commited is database programming, Web Component Certification has to do with Servlet and so on. That is at least what I found in a three minute effort. What is Response Commited in Sun Certified Web Component Developer for the Java Platform, Enterprise Edition 5 (CX-310-083)?

I am sure I understand your question, you are asking when the activity of the Web Component is complete. I am responding that Response Commited is database programming.


Hi Nicholas,

I read a note in HFSJ book second edition (page 207), it says that you cant forward the request if you've already committed a response, my question was when the response is considered to be committed, its not about the database like when you commit a transactions on the database, no, its about the response.

I hope you understand my question.

Many thanks for you reply.
Nicholas Jordan
Ranch Hand

Joined: Sep 17, 2006
Posts: 1282
Yes, I saw something like that recently - it has to do with headers and so on. I can look it up for you: I have Marty Hall's book. The 'committed' you speak of has someting to do with - I am needful of going back and will probably have to fix my statement but you have to do the header stuff BEFORE you get the PrintWriter ( or possibly before you write anything to it )

Standard out { System.out in Java terminology } is obtained by a method call for the Response object and will be documented - Once you write to the browser, buffering and so on is such that changing headers at that point will not work.

We can thus use the nomenclature 'committed' and I would think this is what the authors likely intended. I do not have a copy of that book. A very short citation from the text of a sentence or two to show the question, with a full explaination of what your question is would likely serve clarity for all. Writing a book is like that, and these questions make their job easier. Please elaborate.
Irina Goble
Ranch Hand

Joined: May 09, 2004
Posts: 91
From the Servlet Spec. it seems like it depends on the container (buffering, buffer size). Here is a quote from the specification, SRV.5.1:

The isCommitted method returns a boolean value indicating whether any
response bytes have been returned to the client.
Hussam Odeh
Ranch Hand

Joined: Jul 03, 2007
Posts: 55
hello mates,

my point in this question is to clear a big doubt in a question i solved in chapter 5 (HFSJ the first question) which is:

When using a RequestDispatcher, the use of which methods can often lead to an IllegalStateException?

A- read
B- flush
C- write
D- getOutputStream
E- getResourceAsStream

my answer was (B), but the book mentioned that the answer is (B & C).

I wrote a code to see if the write method cause this exception, but it didnt, only the flush method did this exception.

I hope I managed to clarify my question.

Do anyone have any explanation about this?

[ June 02, 2008: Message edited by: Hussam Odeh ]
[ June 02, 2008: Message edited by: Hussam Odeh ]
Nicholas Jordan
Ranch Hand

Joined: Sep 17, 2006
Posts: 1282
We need to get some testing help, there may be differing responses in implementations. That is hard to deal with in a book. There are short-code weaknesses in what I hammered out in two or three minutes, and others may have improvements right away, but we need to get several responses on this rather than trying to hash it out on one or two observations.


[ June 02, 2008: Message edited by: Nicholas Jordan ]
Marc Peabody
pie sneak
Sheriff

Joined: Feb 05, 2003
Posts: 4727

Originally posted by Hussam Odeh:
I wrote a code to see if the write method cause this exception, but it didnt, only the flush method did this exception.

write won't always cause it... but it could.

I wrote a ditty on autoFlush a little over a year ago that explains this in greater detail.

Enjoy!


A good workman is known by his tools.
Nicholas Jordan
Ranch Hand

Joined: Sep 17, 2006
Posts: 1282
Well this ought be trapped somewhere,....

Consistent behaviour is necessary for writing books.
Ben Souther
Sheriff

Joined: Dec 11, 2004
Posts: 13410

Look at SRV.5.1 in the servlet spec (link in my signature).


The isCommitted method returns a boolean value indicating whether any
response bytes have been returned to the client. The flushBuffer method forces
content in the buffer to be written to the client.


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Response Commited
 
Similar Threads
sendRedirect() javadoc
commiting response
Tomcat Throwing error
Cannot forward after response has been committed? PDF save in Browser?
Cannot forward after response has been committed? PDF save in Browser?