aspose file tools*
The moose likes JSP and the fly likes when exactly response is 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 » Java » JSP
Bookmark "when exactly response is commited?" Watch "when exactly response is commited?" New topic
Author

when exactly response is commited?

ankur rathi
Ranch Hand

Joined: Oct 11, 2004
Posts: 3830


It shows an IllegalStateException on browser.
Why because response is commited before forwarding second time.

But where exactly response is commited???
I never called flush() method and the second way is if buffer automatically fills then it writes content to stream (sent information to client), but I don't think that buffer is filled here...

(And if stream is unbuffered then it would have given error at the first forward itself, but this is also not the case)


Thanks.
[ May 26, 2006: Message edited by: Bear Bibeault ]
Manesh Kumar
Ranch Hand

Joined: Mar 21, 2006
Posts: 94
I think JSP compiler generates the code to commit the response at the end of service method. So when you forward for the second time, the forward method throws IllegalStateException since the response is committed.

We never do ourselves of commiting the response, it usually taken care by the container.


Manesh
ankur rathi
Ranch Hand

Joined: Oct 11, 2004
Posts: 3830
Originally posted by Dilip Kumar Jain:
I think JSP compiler generates the code to commit the response at the end of service method. So when you forward for the second time, the forward method throws IllegalStateException since the response is committed.

We never do ourselves of commiting the response, it usually taken care by the container.


If container generate 'response commiting code' just before the end of service() method then this code anyway will be executed after 'second time forward code'...
Manesh Kumar
Ranch Hand

Joined: Mar 21, 2006
Posts: 94
before the end of service code

I meant for sevice() menthod second jsp file (b.jsp).

After forwarding for the first time to b.jsp (the response will be commited after this), The execution will resume in service method of a.jsp. The second call to forward method will throw an IllegalStateException , resulting halt in execution of service method in a.jsp.

I think this clears your doubt.
ankur rathi
Ranch Hand

Joined: Oct 11, 2004
Posts: 3830
Originally posted by Dilip Kumar Jain:

I meant for sevice() menthod second jsp file (b.jsp).

After forwarding for the first time to b.jsp (the response will be commited after this), The execution will resume in service method of a.jsp. The second call to forward method will throw an IllegalStateException , resulting halt in execution of service method in a.jsp.

I think this clears your doubt.


Thanks Dilip.
Got it.

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: when exactly response is commited?
 
Similar Threads
Enthuware Question ID: 1074483088830
Still confused of forward()
JWebPlus Q
Include Statements
forward happens before service() finishes