wood burning stoves 2.0*
The moose likes Servlets and the fly likes Dont want the control to return to the servlet  and execute after the forward Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Dont want the control to return to the servlet  and execute after the forward" Watch "Dont want the control to return to the servlet  and execute after the forward" New topic
Author

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

Sree Lakshmi Sugunan
Greenhorn

Joined: Feb 29, 2008
Posts: 23
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

Joined: Mar 06, 2001
Posts: 13459

'return' looks correct.
Sree Lakshmi Sugunan
Greenhorn

Joined: Feb 29, 2008
Posts: 23
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

Joined: Dec 11, 2004
Posts: 13410

The call to return needs to be in your doPost, or doGet method.


Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Dont want the control to return to the servlet and execute after the forward