This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes RequestDispatcher forward() Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "RequestDispatcher forward() " Watch "RequestDispatcher forward() " New topic
Author

RequestDispatcher forward()

Mathew Sam
Ranch Hand

Joined: Dec 19, 2001
Posts: 124
Documentation says
forward method should be called before the response has been committed to the client (before response body output has been flushed). If the response already has been committed, this method throws an IllegalStateException. Uncommitted output in the response buffer is automatically cleared before the forward.
But in Tomcat server i am not getting any IllegalStateException ,eventhough i called forward() method after out.close()
why it is so ?

regards,
Sam
Kyle Tang
Ranch Hand

Joined: Aug 22, 2002
Posts: 78
Tomcat is lenient in the sense that it ignores the illegal output after flush()(I tried that before), or, you said you tried close() too.
Tomcat is a freeware and it is not 100% following the spec.
Always follow the spec, and if the exam ask this kind of questions, answer what the spec says, not what tomcat does.


Kyle Tang<br />SCJP 91<br />SCWCD 96<br />SCBCD 95
Mathew Sam
Ranch Hand

Joined: Dec 19, 2001
Posts: 124
Thanks Kyle.
I just wanted to confirm becuase Tomcat is the reference implementation.In fact i tried both flush() and close().

Sam
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
 
subject: RequestDispatcher forward()
 
Similar Threads
Response commited after using some methods
RequestDispatcher.forward()
JSP Include (output of servlet forwarding to JSP)
response.flushBuffer() and jsp:forward
Dispaching a request from Servlet to JSP ERROR (its urgent please help me)