Win a copy of The Business Blockchain this week in the Cloud forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Is return required after requestdispatcher.forward() ?

 
hasan khan
Ranch Hand
Posts: 223
Eclipse IDE Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i have the following code in my servlet doPost().

is it required to have return after rd.forward(request, response); or not ?
 
Amirthalingam Prasanna
Ranch Hand
Posts: 107
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I dont think you need to return statement since when you call the forward you are passing the control to the servlet or jsp anyhow.
 
Ronald Jerue
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello hasaN khaN,

Just because you have a "rd.forward(request, response);" in a method does not mean that nothing else after it will be executed. In your example there is no more code after the "forward" so you would be fine without a "return". But if you did have more code after the "forward" and didn't have a "return" it would be executed.
[ December 28, 2004: Message edited by: Ronald Jerue ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic