[Opensource] how to do a redirect from a controller?
William Boyd
talk2me at telus.net
Fri Mar 28 21:17:31 PST 2003
how to do a redirect from a controller?The error message you are getting
means that some data has been sent to the client browser. As soon as you
send one character through the IO stream to the browser the Response is
committed and you can no longer do a redirect from the controller. I am
using the response.sendRedirect(url) method without problem in my
controller. If you could arrange you logic so that your redirect condition
is the first thing processed response.sendRedirect(url) should work.
Another option but not the prettiest is to write something like this to the
browser.
<script language=javascript>
document.location="[URL]"
</script>
This will do a redirect even if half your content is already written to the
browser but should not be considered an elegant solution. The biggest
problem with this is that a user could see a blank page or half the content
before the redirect occurs.
Good Luck,
Will
-----Original Message-----
From: opensource-admin at jcorporate.com
[mailto:opensource-admin at jcorporate.com]On Behalf Of Thompson, Kris
Sent: March 28, 2003 2:48 PM
To: opensource at jcorporate.com
Subject: [Opensource] how to do a redirect from a controller?
I would like to use the method response.sendRedirect(url) in my process
state but when I try that I get this error
java.lang.IllegalStateException: Cannot forward after response has been
committed
at
org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatch
er.java:368)
at
org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher
.java:356)
This is not an Expresso problem but I wonder how others have done this?
One alternative seems to be to create a redirect.jsp page like is done in
the jsp pages which redirects from the jsp. That would work but I wonder if
there might be a better way.
Thanks
Kris
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mailman.jcorporate.com/pipermail/opensource/attachments/20030328/4b904c51/attachment-0002.htm
More information about the Opensource
mailing list