On Sun, 2003-01-12 at 22:26, Luke Holden wrote:
> On Sunday 12 January 2003 07:33 pm, Edmund Lian wrote:
> > In the end, I just avoided the problem by using redirects. But redirects
> > don't resolve URLs they way Luke (and I) expected. I just wrote my own URL
> > normalizer and wrapped it around .response().sendRedirect()
> Part of the reason why I dont use an external redirect, is so I can pass data
> from one servlet to another on a per request basis. For example... passing
> error information from my login action to the login page.
I solve at least the error case by always making a servlet handle both
the form and the action for the form. Then if the form is successful,
it usually gets (externally) forwarded to another servlet (sometimes
even back to the same servlet, except without the fields that trigger
the action). FunFormKit is designed like this, but I use it with most
of my forms even when I don't use FFK.
> Unless I am missing something... the only other ways to handle this would be:
> 1) Pass the information through the url.
> 2) Pass the information through the session.
No, neither of these are very good solutions. Using sessions for too
much can cause problems with non-linear navigation, for instance when
the user has multiple pages open, or uses the back button to continue
from a previous page.
With the URL, one option you could use is keeping a dictionary in the
session, and generating random keys for each state. You pass the key in
the URL and the page gets the information from the session based on that
key. That would solve some of the problems, though it could cause
memory use you wouldn't want.
A style I also use for all my sites is to have a simple list of messages
that get displayed at the top of the next page to be loaded. So when a
page redirects after doing some action it might just put a message like
"Document deleted" in the session, then do an external redirect to an
index page, and the index page will display the message. This way you
can avoid low-content pages, but also keep the user informed of the
result of their actions.
Ian Bicking Colorstudy Web Development
PGP: gpg --keyserver pgp.mit.edu --recv-keys 0x9B9E28B7
4869 N Talman Ave, Chicago, IL 60625 / (773) 275-7241