It's not a secret anymore!
The moose likes Web Component Certification (SCWCD/OCPJWCD) and the fly likes flush() in rd.include vs rd.forward() Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Certification » Web Component Certification (SCWCD/OCPJWCD)
Bookmark "flush() in rd.include vs rd.forward()" Watch "flush() in rd.include vs rd.forward()" New topic

flush() in rd.include vs rd.forward()

luke brown
Ranch Hand

Joined: May 15, 2014
Posts: 31
i have the following code snippet in my web app:

When i am using flush before Forward(), its throwing illegalstateexception (since the response is sent the moment we call flush and later we are trying to resend the response using forward) but the code works fine even after i provided flush before the rd.include(). Why doesnt it throw the exception here?

Frits Walraven
Creator of Enthuware JWS+ V6
Saloon Keeper

Joined: Apr 07, 2010
Posts: 2043

The include method of the RequestDispatcher interface does not throw an IllegalStateException.

Just check the Servlet 3.0 specs chapter 9.3 (The Include Method) and 9.4 (The Forward Method)
I agree. Here's the link:
subject: flush() in rd.include vs rd.forward()
jQuery in Action, 3rd edition