• Post Reply Bookmark Topic Watch Topic
  • New Topic

Cannot forward after response has been committed  RSS feed

 
S bitz
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
This is my code



and this always shows a Cannot forward after response has been committed error when res is false.

Can anyone help me with this? What am i doing wrong here?

Thanks,
Bitz
 
dema rogatkin
Ranch Hand
Posts: 294
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
out.close();
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes, that is a very strange thing to do.
 
S bitz
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Dema,

I commented the out.close and it worked fine. But can u help me understand why this was the reason ?


Thanks,
Bitz
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
when you 'forward' or 'include', the same request and response is passed to that resource. If you close the output stream, it cannot be used by the JSP to return the data. As soon as any data gets written to the client, the response is 'committed', and if you check the API, closing the Writer also flushes it (ie sends the data). Since you set the content type first it also ensures that there is data to be sent.
 
S bitz
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks David,
that made things much clearer now.


Bitz
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!