Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

I have no idea why this is happening

 
Subbu Aswathanarayan
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi all,
i found out something very strange thing abt servlets.i dont know if i am right but anyway....
in one of my servlets, if a particular condition is met i forward the request to a certain jsp page

and if the condition is not met i do some other processing in the servlet itself.today i realized that the request comes back to this servlet after the jsp page execution is over.till now i believed that once request has been forwarded, the control passes on to the called servlet/jsp page.
am i right?if i am right what should i do so that the request doesn't come back to the calling servlet.i know i can use the else condition.but in my case there are situations where i cannot use else condition
any help would be greatly appreciated.
Subbu
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13074
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
According to the API, when the call to forward returns, the response output stream should be flushed and closed, so your calling servlet should not be able to write anything more. However, the thread that calls forward does return to the calling method, so you can do other stuff.
Bill

------------------
author of:
 
Subbu Aswathanarayan
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks bill for your response.
is there anyway i can prevent the execution of the code after the forward statement.can i use something like exit just after the forward statement.is it advisable?
thanks.
Subbu
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic