I come across this problem when I want to have a 'hidden' servlet that
does form processing and then redirect to some other URL. An example
might be to have an 'Edit.py' servlet that has a form whose action is
"doEdit.py" which processes the data and either redirects back to
Edit.py (on a validation error) or goes on to Display.py to display
that data just edited. Pseudo code:
# display the form
# where <form action="doEdit">
# and pull data from session if it's there
def awake(self, transaction):
# process the data in self.request().fields()
# on error:
# set session to values from Edit.py
# on succeed:
# clear session, and
# display the object in question
The reason I like to do it this way (and maybe there's a better
solution to it) is that if I put all of this functionality into one
servlet using actions and the _action_=<action> keyword in the form,
then that posted form data is still there in the browser and once a
person has edited the data and is viewing their changes, they can hit
refresh/reload and the browser will want to repost the data.
The problem, though, is that IE gives us problems like you mentioned in
that it is very unreliable when setting cookies and doing redirects at
the same time.
Does anyone else have a successful pattern they use when dealing with
On Friday, November 21, 2003, at 08:47 AM, Max Ischenko wrote:
> I (and probably other) have struggled a nasty problem occurred when
> WebKit used as an application server behind a IIS. Here I'd like to
> give a simple solution for those interested and (may be) to be
> included in the next Webware release.
> Problem description: When you put some data on your session object and
> redirects to another WebKit page you don't find the data. In fact, you
> could discover that you have another (brand new) session object!
> Explanation: This is due to the fact how WebKit implements session
> support and how IIS handles redirects (HTTP 303). When new session is
> created, WebKit sets cookie _SID_ and pass it along with response
> (which happened to be a redirect). But unfortunately, IIS don't pass
> the redirect to browser. It does "internal redirect" and goes for the
> url specified in it. While doing this the _SID_ cookie is lost and
> WebKit starts another new session as it doesn't see the SID.
> Solution: Pass _SID_ in a URL instead of a cookie so that it wont
> lost. WebKit would check the query string as well when looking for >
> Here is how I do it (in my custom Page class):
> def injectIntoUrl(url, name, value):
> "Injects a parameter with specified name and value into URL."
> if '?' in url:
> return "%s&%s=%s" % (url, name, value)
> return "%s?%s=%s" % (url, name, value)
> class SitePage(Page):
> # ...
> def sendRedirectAndEnd(self, url):
> sid = self.session().identifier()
> url = injectIntoUrl(url, '_SID_', sid)
> Page.sendRedirectAndEnd(self, url)
> Hmm. Just realized that is not a perfect solution if redirect can go
> outside WebKit, so an improvement is wellcomed.