Hi Martin,

1. You better syncronise on the current session rather than servlet's
   methods, wich are shared betwen different browsers (and users):
  this may be done with something like:

public void
  doPost_or_Get(
      HttpServletRequest req,
      HttpServletResponse res
  )
       throws <usual exceptions>
{
    HttpSession usersSession = req.getSession(true_or_false);
    // the following block will be executed concurently only for
    // diferrent HttpSessions -
    // the same user's requests will wait for each other to return...
    synchronised(usersSession) {

      // put here normal code.

    }
}

-------
The previous code prevents a servlet to become a tight resource
claimed by many users, as when you synchronyse on servlet's calls
synchronised doSomething() ...

One other advantage may be that different servlets may synchronise this way
on the same session - for example if a JDBC result set, preserved as
session resource is accessed from two different servlets, they will
wait each other too.

Others may criticise this approach. Probably a deeper synchronisation
like on the resultset itself is better.

------------

2. Not by cookies or other headers. I think.
   Mabe on what "pages" they contain, what urls they link-to.

   One might try with javascript to put some sort of "window-name" in
   query-strings, so servlets may find what window request came from.


3. Servlets usualy handle more than one simultaneous same-user request
   that's their default behaviour.
   Depends on what logic you want to implement if necessary to put
   some synchronisation here or there.

   Hope previous example will help.
--------------------------------------
Bye!

Cezar



On Fri, 12 Mar 1999, Martin Eberle wrote:

> Hi David,
>
> 1. How do you block a second request from a servlet (synchronize it's methodes?)
>
> 2. Is there really no way to differnetiate between the two browser instances?
>     (a second instance = Netscape Browser: 'File' -> 'New' -> 'Navigator Window')
>
> 3. So it will be impossible to handle more than one request from the same user!
>     -> because all browser instances work with the same cookie-information
>       --> so the servlet seems to handle only the last request!
>
>
> if anybody knows to handle this, please help me out here.
>
> thanks martin
>
>
> David Ezzio wrote:
>
> > Martin,
> >
> >    Cookies are, I believe, unique to the machine or at least the
> > directory where the browser is installed.  So multiple instances of the
> > browser from the same install share the same cookie.
> >
> >    On the other side, you don't need multiple browsers to generate
> > multiple HTTP requests that overlap.  Simply hit the reload button
> > twenty times and your servlet will be running 20 threads all trying to
> > serve the same stuff for the same session to the same browser.
> >
> >    This second situation can be prevented by blocking subsequent threads
> > from entering the session until the thread that has entered has exited.
> > But in your case, because of the cookie thing, I'm not sure that would
> > make a difference in behavior for you.
> >
> > David
> >
> > Martin Eberle wrote:
> > >
> > > !! A user opens two instances of the same browser !!
> > >
> > > So there can be two ore more call's to a servlet (with the same
> > > sessiondata) !!
> > > ->That means: What about the members of helper-classes ?
> > >  -> how can I synchronize this situation ?
> > >
> > > Specific problem:
> > > My servlets serve as an ecommerce-system:
> > > 1. To navigate through the resultset of a database-query I set a cookie
> > > (identifies set of products) to the client
> > > 2. The user post two simultanious querys -> the slower query-process
> > > sets the final cookie.
> > > 3. So the user navigate in both browser windows throw the same set of
> > > products!
> > >
> > > thanks martin
> > >
> > > ___________________________________________________________________________
> > > 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
>


Cezar Totth                             email:  [EMAIL PROTECTED]
                                        Fax:    (401) 220 33 95
Genesys Software Romania                Phone:  (401) 638 49 44
Stefan Furtuna 169, sect.6
cod 77171, Bucharest
Romania

___________________________________________________________________________
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

Reply via email to