Erik:
I've taken the approach of insisting on a valid session, with a "UserName"
value in the session to identify a logged in user. If they start a window
that starts a new session, the first thing they try to do in that window
will insist they log in (unless they've stored a local cookie, which can do
it for them - but that's got it's own problems). Once the new window is
logged in as the same user (even though a different session), I can
associate things they are doing in either session together (e.g. if they buy
something in each session they both end up in the same cart, 'cause they're
the same user).
As far as not overwriting query results (like in your search example), I'd
handle that by merging query results done by the same user, so he'd see
results for blue & green widgets together until he hits something like "new
search" to clear his results & start again (in any session).
Effectively I'm merging all sessions that are logged in as the same user and
treating them as one.
You can see this in action at http://www.javacorporate.com in our online
demo of Expresso - Register yourself to get a username/password, then do
some permitted function (like list events on the "Events" page). Then open a
new window (if you're in netscape) and list again. You'll get a message that
you can't do that 'cause you're not logged in if it starts a new session.
Obviously this is an issue that has to be dealt with in doc or user training
(if you're doing an intranet site & have some idea who your users will be,
of course!).
Mike
> -----Original Message-----
> From: A mailing list for discussion about Sun Microsystem's
> Java Servlet
> API Technology. [mailto:[EMAIL PROTECTED]]On
> Behalf Of Erik
> Hanson
> Sent: Thursday, August 19, 1999 7:03 PM
> To: [EMAIL PROTECTED]
> Subject: Sessions & multiple windows in the real world
>
>
> This is addressed to people who have written real,
> non-trivial applications
> using sessions: how have you handled users who open multiple windows
> (instances of the browser)?
>
> There are two ways the session mechanism handles multiple,
> and different
> browsers cause them to happen under different circumstances:
>
> 1. Each window is a separate session
> 2. Both windows share a session
>
>
> #1 can be bad sometimes. For example, a Netscape for Windows
> user gets a
> list of widgets from my (hypothetical) widget store,
> eWidgets.com. She is
> interested in UltraWidget, so she clicks on the "purchase"
> link. UltraWidget
> is then added to her shopping cart. The shopping cart info is
> stored in a
> session.
>
> She sees an ad on the page for "UltraWidget Extended
> Warranty" which she is
> interested in. She right-clicks on the link and chooses "Open
> link in new
> window" so she can read about it in a new window. Because of the way
> Netscape works, the new browser window means a new session.
> She wants to buy
> the extended warranty so she clicks the "Add to shopping
> cart" link and it
> is added to her shopping cart.
>
> But because she has two sessions going on, only the extended
> warranty is in
> her shopping cart. She gets confused and starts swearing and turns her
> computer off, cheating me out of a $45,000 widget sale.
>
> Had she been using Internet Explorer for Windows, both
> windows would have
> shared a session and she wouldn't have gotten confused.
>
>
> #2 can be bad sometimes too. For example, an Internet
> Explorer for Windows
> user wants to find all blue widgets and all green widgets, so
> he goes to the
> search page of eWidgets.com and types in "blue" and hits "search".
>
> When his results come back, he remembers that he also wants
> green widgets,
> so he chooses "New Window" from the "File" menu which gives
> him a duplicate
> window (and which shares the same session). He types "green" and hits
> "search" and gets back a list of results.
>
> He then goes back to the first window (the one with the blue
> widgets) and
> clicks the "next page" link, which shows him the next page of *green*
> widgets, because the search results were stored in the
> session and the green
> results overwrote the blue results. He gets annoyed and starts playing
> Quake, cheating me out of some widget sales.
>
> Had he been using Netscape for Windows, each window would
> have had its own
> session and the search results wouldn't have gotten mixed up.
>
>
> So what do *you* do about sessions an multiple windows? Just
> hope that users
> don't open multiple windows? So far, I've been ignoring
> sessions and passing
> parameters around, but I'm writing a complex application and
> the parameter
> passing is getting out of hand.
>
>
> Thanks in advance,
> Erik
>
> ______________________________________________________________
> _____________
> To unsubscribe, send email to [EMAIL PROTECTED] and
> include in the body
> of the message "signoff SERVLET-INTEREST".
>
> Archives: http://archives.java.sun.com/archives/servlet-interest.html
> Resources:
http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html