Actually, I am not sure that the EXACT behavior of the JSP engine is defined
with respect to the behavior after a forward is issued, at least I haven't
seen it.

I was under the impression that issuing a forward would go and process the
request on the same thread in the new servlet and then return back to the
original servlet, on the same thread, just as it seems everyone has
suggested.

It has been my experience however that such is not the case, at least with
JRUN.  I realize JRUN is a specific JSP engine, but the point is that it is
not specified in the spec, and thus different behaviors, I believe, have
been implemented by different engines, and my only experience comes from
JRUN, which behaves counter-intuitively.

The tricky thing about JRUN is that the forward seems to submit an item into
the request queue, rather than process the request immediately, thus the
next statement after the forward is executed immediately afterward, or
rather simultaneously with the new request along with any other requests.

Doing a return after a forward is definitely the best behavior, but the
nasty thing about JRUN is that the best place to put cleanup code and the
like is AFTER you have completed your response to your user, but before the
request has completed at the servlet side, thus improving the user's
impression of response time.

Unfortunately with JRUN, the call to forward is asynchronous, rather than
synchronous, so you're not guaranteed anything about the execution times of
the forwarded request and the code following the forward, and so putting in
this kind of cleanup code is a bit more involved than it might have been had
the forward call executed synchronously.

Just my $.02,

-tg
----- Original Message -----
From: Mike Engelhart <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, August 17, 1999 8:50 AM
Subject: Re: Long process


> Thanks.  That's a good idea about putting a return in after the forward
> call.   Saves a few CPU cycles/RAM chunks here and there which is always
> good with Java
>
> Mike
>
> ----------
> >From: "Craig R. McClanahan" <[EMAIL PROTECTED]>
> >To: Mike Engelhart <[EMAIL PROTECTED]>
> >Cc: [EMAIL PROTECTED]
> >Subject: Re: Long process
> >Date: Tue, Aug 17, 1999, 10:43 AM
> >
>
> > Mike Engelhart wrote:
> >
> >> IAlso on a related note, does forwarding a request to a JSP make the
servlet
> >>
> >> return from it's service method or does it continue until it's
finished?
> >>
> >
> > If you are using <jsp:forward> in a JSP, you can think of this as a "go
to"
> > statement.
> >
> > If you are using RequestDispatcher.forward() in a servlet, the method
call
> > *does* return.  However, you are no longer able to modify the response
in any
> > way.  I just stick a "return" statement after my calls to the forward()
> > method.
> >
> >>
> >> Thanks,
> >>
> >> Mike
> >>
> >
> > Craig McClanahan
> >
>
>
===========================================================================
> To unsubscribe, send email to [EMAIL PROTECTED] and include in the
body
> of the message "signoff JSP-INTEREST".  For general help, send email to
> [EMAIL PROTECTED] and include in the body of the message "help".
> For JSP FAQ, http://www.esperanto.org.nz/jsp/jspfaq.html
>

===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JSP-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".
For JSP FAQ, http://www.esperanto.org.nz/jsp/jspfaq.html

Reply via email to