| Author |
Illegatstateexception !!!
|
Nishant Dhar
Greenhorn
Joined: Sep 09, 2005
Posts: 26
|
|
hi, I understand that if I commit the response in some way by doing a write(), println() or a flush before I do the sendRedirect or RequestDispatcher forward, I will get an illegalstatexception. But what happens if I try to write to the response in the forwarding servlet after the sendRedirect or RequestDispatcher method call. Thanks !!! Nishant
|
 |
Bosun Bello
Ranch Hand
Joined: Nov 06, 2000
Posts: 1506
|
|
|
You have forwarded the request/response objects, so you have transferred control, and you should get an exception.
|
Bosun (SCJP, SCWCD)
So much trouble in the world -- Bob Marley
|
 |
Troy Peter
Greenhorn
Joined: Oct 13, 2005
Posts: 14
|
|
Hi Nishant, I haven't tried that before but my guess is if you try somehow to write to the response after the forward call then nothing is going to happen (code not executed) since control will have been already transferred to the forwarded page. Troy.
|
 |
Narendra Dhande
Ranch Hand
Joined: Dec 04, 2004
Posts: 950
|
|
Hi, Let me try to explain the above case. 1. The servlet call the requestDispatche forward method. let the response is not committed so no problem. 2. After successfully executing the forward method. it will return to next line os the forward message. 3. Here the execution of the code in original servet resumes, but the response is committed so there is no way to display anything on the browser. 4. As you try to write somthing on the out, it throw the exception but can not show to the client as the response is already committed. But I can see the exception in server log. Thanks
|
Narendra Dhande
SCJP 1.4,SCWCD 1.4, SCBCD 5.0, SCDJWS 5.0, SCEA 5.0
|
 |
 |
|
|
subject: Illegatstateexception !!!
|
|
|