On Fri, 4 Apr 2003, Velmurugan (Java Team) wrote:
> Date: Fri, 4 Apr 2003 12:05:14 +0530 > From: "Velmurugan (Java Team)" <[EMAIL PROTECTED]> > Reply-To: Tomcat Users List <[EMAIL PROTECTED]> > To: Hans Schippers <[EMAIL PROTECTED]> > Cc: [EMAIL PROTECTED] > Subject: Re: does the getRequestDispatcher().forward() method return > control? > > Hi, > > I think this is a bug as per the servlet specification.Just check with some > other servlet engine. I will forward this error to tomcat developer list. I > was tested with Tomcat3.2.2. > > Velmurugan P. > Java Team. > > ----- Original Message ----- > From: "Hans Schippers" <[EMAIL PROTECTED]> > To: <[EMAIL PROTECTED]> > Sent: Thursday, April 03, 2003 1:44 AM > Subject: does the getRequestDispatcher().forward() method return control? > > > > Hi, > > > > if in a servlet, I have some code like: > > > > getServletConfig().getRequestDispatcher("/my/page.jsp").forward(request, > > response) > > > > Is it supposed to return control to the servlet afterwards? > > A call to RequestDispatcher.forward() is just like any other Java method -- there is no magic here. Control is indeed returned to the line after this line once it completes. Java doesn't have anything like a longjmp() in C, so the only other possibility would be that the code inside the forwarded-to servlet threw an exception -- but your code above would still have a chance to catch that if you put it inside a try/catch block. > > >From what I find on the net, it isn't, but when I try to print something > > to System.out after the forward call, that works... > > As above, control is absolutely returned. However, there are some restrictions on what you can do afterwards -- in particular, you can no longer write to the response (it is assumed that the forwarded-to servlet took care of that already), so the only prudent thing to do is "return". > > So did I misread on the www, or is this some bug in my webserver? > > > > I'm using JBoss/Tomcat btw... > > > > Thanks, > > > > Hans > > Craig --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]