> > Simple question .. In asp, there's a response.end .. which
> > terminates the activity of the ASP page.  Is there an equivalent,
> > or do I just EXIT (0);
> >
> > Hoping there's a cleaner way!
>
> By default, you don't need to do anything at all.  At the end of
> your JSP page, the generated code flushes the output stream for you,
> and gets ready for the next request.
>
> If you want to terminate the output at a particular point, the
> simplest way would be with a Java Scriptlet like this:
>
> <%
>     out.flush();
>     return;
> %>

In some situations this doesn't suffice.  For example, when you call a
utility class to generate your page and that class decides it need to do
a redirect.  There's no easy way for it to say "we're done here, no more
output".

Picture you're writing a class to detect if the client supports
cookies.  In ASP, the utility could do the work without bothering the
programmer.  How it works is first thing in your page, ask the utility
getCookieSupported().  If the utility doesn't know the answer, it does a
redirect (with a test cookie) to check and calls response.end.  The ASP
caller never knows control was taken away.  But the next time the client
visits the ASP page the getCookieSupported() call returns a valid true
or false.  Snazzy, but not possible in JSP near as I can tell.

Seems a limitation of a stack-based language.  Best you could do is set
a flag to have future response output ignored.

-jh-

P.S.  To the original poster, don't call System.exit().  That would be
asking the server to exit execution.

--
Jason Hunter
[EMAIL PROTECTED]
Book:    http://www.servlets.com/book
Article: http://www.javaworld.com/jw-12-1998/jw-12-servletapi.html

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
FAQs on JSP can be found at:
 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.html

Reply via email to