Hi Y'all
if you want to find out how and on what variables to synchronize take a look at
the servlet java-code that was generated from a jsp page as first step of
translation. This was a valuable resource of information to me.
Peter
Bo Xu wrote:
> Paul Foxton wrote:
>
> > Hi Bo, thanks for your reply
> >
> > I think I follow you, and you seem to be saying the same things as Hans,
> >
> > apart from this part:
> >
> > > no, but please notice that this local/method can not refrence to a
> > > instance/static
> > > field of MyServlet, or refrence to a object shared by several
> > > Threads, for
> > > example:
> > > doGet(...){
> > > ...
> > > HttpSession session=req.getSession();
> > > session.getAttibute(...)/setAttibute(...);
> > > ...
> > > }
> > >
> > > session is a local variable, but because it references to
> > > req.getSession(), so
> > > I think "synchronized" need to be used here
> > >
> >
> > - isn't the point of the getSession method is that a new instance of the
> > Session object is created for each new request, so each new thread spawned
> > by a request would have its own instance of Session?
> >
> > Hope I havn't misunderstood you.
> >
> > thanks,
> >
> > Paul
> > [...]
>
> Hello Paul, I find it is not suitable to use HttpSession as the sample for
> Thread/local-variable issue in my last email, it make the explaination more
> complicated :-) because I found(with TC4.0b5), for every req,
> session.hashCode()
> is different, even if session.getId() is same.
>
> I still guess session.getAttibute(...)/setAttibute(...) need to be
> "synchronized",
> but perhaps I can not use session itself to do it, I think it is possible to
> use a
> context-wide object as "mutex".
>
> so I think I need to use another sample:
>
> doGet(...){
> ...
> ServletContext context = getServletContext();
> context.getAttibute(...)/setAttibute(...);
> ...
> }
> context is a local variable, but because it references to
> getServletContext(), so perhaps "synchronized" need to be
> used here.
>
> have a nice afternoon :-)
>
> Bo
> July 16, 2001
>
> ___________________________________________________________________________
> 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
--
*** Bitte beachten Sie unsere neuen Mail- und Internet-Adressen ***
*** Please notice the new mail- and internet-address ***
--
___________________________________________________________________________
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