Chenming Zhao elucidated:

> In fact I output the loginname. But here, when the problem happened, still
> the loginname was updated. So the problem is that the loginname was
updated,
> then the username cannot get the right value. But when I tested it on
> different computer, it's correct.
   ^^^^^^^^^^^^^^
> So I wonder why there is the problem when
> I open windows for multiple users.

This is just a guess, but try using two separate browsers (ergo, Netscape
and Opera) on the same machine, too.

Looking at your code, it is not clear whether numEvents is coming from some
database owned by the server or from a variable in the browser's
"environment".

I'm not sure what the terminology in Tomcat/JSP, but the "environment"
variables from the browser are not necessarily flushed unless you shut the
browser application program itself down. It's not even good enough to close
one window if you have other windows of the same browser open. Since you are
trying to access simultaneously, there is no way you would be able to shut
the browser down before logging in as the second user.

Browsers don't know much about sessions except for the cookie or query part
of the URL in the link that the server might build.

HTH.

Joel Rees
Alps Giken Kansai Systems Develoment
Suita, Osaka


> Is it the problem of the server or
> setting?
>
> ----- Original Message -----
> From: "Wagoner, Mark" <[EMAIL PROTECTED]>
> To: "'Tomcat Users List'" <[EMAIL PROTECTED]>
> Sent: Tuesday, March 26, 2002 3:28 PM
> Subject: RE: AW: Multiple users share java bean?
>
>
> > Are your sure loginname is getting set properly?  Try including the
value
> in
> > your JSP output (right before the call to mb.test()) just to make sure.
> >
> > -----Original Message-----
> > From: Chenming Zhao [mailto:[EMAIL PROTECTED]]
> > Sent: Tuesday, March 26, 2002 3:05 PM
> > To: Tomcat Users List
> > Subject: Re: AW: Multiple users share java bean?
> >
> >
> >
> >
> > ----- Original Message -----
> > From: "Wagoner, Mark" <[EMAIL PROTECTED]>
> > To: "'Tomcat Users List'" <[EMAIL PROTECTED]>
> > Sent: Tuesday, March 26, 2002 2:12 PM
> > Subject: RE: AW: Multiple users share java bean?
> >
> >
> > > Are you sure you really want independent instances of the bean, or
just
> > the
> > > ability to keep the variable values separate by user?  If it is the
> > latter,
> > > then just use local variables in your bean methods.
> > >
> >
> > It seems that couldn't work. The value of such variables can be updated
by
> > another user's when there are two or more users calling the same java
bean
> > almost at the same time. Here is my main work. First jsp write uname
(when
> a
> > user login the website, there is a user name "uname") to the bean and
> > activate it, and get the result  or save it to the database.
> >  Jsp file:
> > <jsp:useBean id="mb" class="mybean.test" scope="page" />
> > ???How about the scope value? session or request or page?
> > <jsp:setProperty name="mb" property="uname" value="<%=loginname) %>"/>
> > <p>The result is:
> > <%= mb.test() %></p>
> >
> > Bean code:
> > public class test
> > {
> >     String uname= "";
> >
> >     public synchronized int test()
> >     {
> >         int real=0;
> >         int eventCounter=0;
> >         int numEvents;
> >
> >         // connect to the database and get the numEvents according to
the
> > uname.
> >         .........;
> >
> >         while(eventCounter<=numEvents)
> >         {
> >             real=eventCounter;
> >
> >             // wait for 0.01 second
> >             try{wait(10);}
> >             catch(InterruptedException e){};
> >             eventCounter++;
> >         }
> >         return real;
> >     }
> >
> >     public synchronized void setUname(String sec)
> >     {
> >         uname= sec;
> >     }
> > }
> >
> > For user1, numEvents=100; and user2, it's 120. So I want to run them at
> the
> > same time, and hope to get resuls 100 and 120 respectively. But in fact
I
> > got both 100 or 120. Have any idea? If my description is not clear, tell
> me
> > please.




--
To unsubscribe:   <mailto:[EMAIL PROTECTED]>
For additional commands: <mailto:[EMAIL PROTECTED]>
Troubles with the list: <mailto:[EMAIL PROTECTED]>

Reply via email to