Win a copy of The Little Book of Impediments (e-book only) this week in the Agile and Other Processes forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Redirection and forwarding in servlets

 
Tony romer
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I write some contents to response out object but did not flush or commit.

Then I get dispatcher and forward it?

OR I use response.sendRedirect?

What are the results?
 
Bryan Basham
author
Ranch Hand
Posts: 199
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Tony,

It depends upon how much content servlet pushed to the response writer (or output stream). The web container will buffer some content and throw that content away if the servlet forwards to a ReqDisp or does a redirect.

However, if the servlet pushed more content than the buffer can hold, then the web container is required to commit that buffer (and the response header) to the browser. After that has happened, any attempt to forward or redirect will fail.

Regards,
Bryan
[ July 24, 2008: Message edited by: Bryan Basham ]
 
Tony romer
Ranch Hand
Posts: 32
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thats great answer.
Thank you
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic