• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

HFSJ Dumb Question on <jsp:forward>

 
Jay Shukla
Ranch Hand
Posts: 214
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In HFSJ on page No. 416, They have explained that Never use flush and foward togeather.

to Explain this they gave following code with explanation:



Explaination:
========
the Container dutifully commits(sends) "Welcome to our page!" as response and sees <jsp:forward> then it throws an IllegalStateException.

Except nobody will see the exception! The client sees "Welcome to our page!" ... and nothing else. The forward throws an exception but it's too late for the Container to take back the response. So the client sees what was flushed, and thats it. The forward doesn't happen, the rest of the current page doesn't happen. End of story for tht page. So never do a flush-and-forward!


In above explanation i know the reaon for an exception (as it commits reponse and then try to forward the jsp), but i didn;t understand whay they are trying tp explain by telling "The forward throws an exception but it's too late for the Container to take back the response. So the client sees what was flushed, and thats it. The forward doesn't happen, the rest of the current page doesn't happen. End of story for tht page."

Can anyone please explain.

Thanks in Advance.
 
Balu Sadhasivam
Ranch Hand
Posts: 874
Android Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


Jay,

flush() will enforce to send the data from buffer to the network and definitely cant get back , hence they have mentioned "but it's too late for the Container to take back the response. "

Also to note is that default buffer value to flush out is 8KB in jsp. Any data written fills buffer value, it implicilty calls flush() ,eventhough flush is not specifed in this case.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic