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 Writing to response after 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 "Writing to response after forward??" Watch "Writing to response after forward??" New topic
Author

Writing to response after forward??

Anand Wadhwani
Ranch Hand

Joined: Mar 21, 2005
Posts: 151
Be it dispatcher.include or dispatcher.forward, these are just method calls and the java execution control does comes back to caller. What if I try to write something to response after forward(). I am getting lazy in doing it on tomcat, does anyone know already if it will throw IllegalStateException or will just ignore the data wrote to response after forward?

BTW, just to share, data wrtten to response after response.sendError() are ignored and IllegalStateException is not thrown.
[ June 19, 2005: Message edited by: Anand Wadhwani ]

SCWCD 1.4<br />---------------------<br />Ability is what you're capable of. <br />Motivation determines what you do. <br />Attitude determines how well you do it.<br />---------------------
PNS Subramanian
Ranch Hand

Joined: Jul 13, 2004
Posts: 150
This is what i had in my code


This was the exception i encountered (as expected)


java.lang.IllegalStateException
org.apache.coyote.tomcat5.CoyoteResponseFacade.sendError(CoyoteResponseFacade.java:325)
com.servlet.TestServlet.doGet(TestServlet.java:49)
com.servlet.TestServlet.doPost(TestServlet.java:30)
javax.servlet.http.HttpServlet.service(HttpServlet.java:709)
javax.servlet.http.HttpServlet.service(HttpServlet.java:802)

Anand Wadhwani
Ranch Hand

Joined: Mar 21, 2005
Posts: 151
Thanks Subramanian!
 
Don't get me started about those stupid light bulbs.
 
subject: Writing to response after forward??
 
Similar Threads
Please answer these few doubts
Response already Committed
Cannot forward after response has been committed? PDF save in Browser?
RequestDispatcher.forward()
Cannot forward after response has been committed? PDF save in Browser?