• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • paul wheaton
  • Ron McLeod
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Paul Clapham
Saloon Keepers:
  • Tim Holloway
  • Carey Brown
  • Piet Souris
Bartenders:

HFSJ Dumb Question on <jsp:forward>

 
Ranch Hand
Posts: 214
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 874
Android VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic