tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Craig R. McClanahan" <craig...@apache.org>
Subject Re: does the getRequestDispatcher().forward() method return control?
Date Fri, 04 Apr 2003 22:05:28 GMT


On Fri, 4 Apr 2003, Velmurugan (Java Team) wrote:

> Date: Fri, 4 Apr 2003 12:05:14 +0530
> From: "Velmurugan (Java Team)" <webteam@nallisoft.com>
> Reply-To: Tomcat Users List <tomcat-user@jakarta.apache.org>
> To: Hans Schippers <saintman@PANDORA.BE>
> Cc: tomcat-user@jakarta.apache.org
> 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" <saintman@PANDORA.BE>
> To: <EJB-INTEREST@JAVA.SUN.COM>
> 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: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Mime
View raw message