Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Dont want the control to return to the servlet and execute after the forward

 
Sree Lakshmi Sugunan
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I use requestDispatcher.forward under an if condition in my servlet. After this line there are some code. I dont want the control to come back and execute the code. Is there are any option we can set in the request or response so it doesnt come back to the servlet.

eg:

if(LOBList == null || LOBList.isEmpty())
{
req.setAttribute(LaserConsts.LOBEXCEPTION,"loberror");
getRequestDispatcher(LaserConsts.ERROR_PAGE).forward(req, res);
return;
}


remaining code
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
'return' looks correct.
 
Sree Lakshmi Sugunan
Greenhorn
Posts: 23
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Actually this method is called by some other methods so even if I put return it will go back to tht method and execute the remaining part of the following methods. So return doesnt work in my case. Is there any other option that the control soesnt come back itself.
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The call to return needs to be in your doPost, or doGet method.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic