RequestDispatcher.forward doesn't transfer control to jsp.
0 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Joan_Lansing
Posted On:   Thursday, September 20, 2001 01:13 PM

My servlet does some processing, and under certain conditions, forwards to a jsp A. If the conditions are not met to forward to jsp A, there is more code to process. My problem is that whether or not I forward to jsp A, the additional code is executed. Doesn't the forward transfer control to the jsp? Why is processing continueing in the servlet after the forward? I have tried adding a "return" statment, but that did not help because I'm actually calling from another method and the logic then continues on in the calling method. Sample code: if(a) { getServletConfig().getServletContext().getRequestDispatcher("myjsp.jsp").forward(request,response)   More>>

My servlet does some processing, and under certain conditions, forwards to a jsp A. If the conditions are not met to forward to jsp A, there is more code to process.


My problem is that whether or not I forward to jsp A, the additional code is executed. Doesn't the forward transfer control to the jsp? Why is processing continueing in the servlet after the forward? I have tried adding a "return" statment, but that did not help because I'm actually calling from another method and the logic then continues on in the calling method.


Sample code:

			

if(a)

{
getServletConfig().getServletContext().getRequestDispatcher("myjsp.jsp").forward(request,response);

}

performNextMethod();



The method "performNextMethod" gets executed even if condition a is true. Why and how do I stop it?

   <<Less
About | Sitemap | Contact