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. 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.
>
>
> > -----Original Message-----
> > From: Chenming Zhao [mailto:[EMAIL PROTECTED]]
> > Sent: Tuesday, March 26, 2002 2:06 PM
> > To: Tomcat Users List
> > Subject: Re: AW: Multiple users share java bean?
> >
> >
> > What's the meaning of JMS? I'm not sure my problem is just what you
said.
> I
> > want to get independent instance or the same bean for each user. So they
> can
> > work independently, and won't influence with each other. Thanks.
> >
> > ----- Original Message -----
> > From: "peter lin" <[EMAIL PROTECTED]>
> > To: "Tomcat Users List" <[EMAIL PROTECTED]>
> > Sent: Tuesday, March 26, 2002 1:32 PM
> > Subject: Re: AW: Multiple users share java bean?
> >
> >
> > >
> > > One common technique to solve this is to use JMS. All beans that are
> > > instances of the same user listen to the same topic. when one instance
> > > of the user's bean is updated, the other instances are notified. Each
> > > bean then goes to the database to refresh itself.
> > >
> > > peter lin
> > >
> > >
> > > Chenming Zhao wrote:
> > > >
> > > > In fact, it's a good and difficult topic. Now I haven't still
> understood
> > it
> > > > completely. I have a question about my application.
> > > >
> > > > I describe the work what I need to finish.
> > > > First the jsp file gets a user name, then pass it to java bean. And
> the
> > bean
> > > > get some values from the database accoding to the user name, then
get
> a
> > > > result and save it to database. The idea of synchronized objects
> cannot
> > > > work. I want to acitvate independent instance of java bean for any
> user.
> > How
> > > > can I do? Is there any good book or material? Or maybe you can show
me
> > some
> > > > simple example?
> > > >
> > > > Thanks.
> > > >
> > > > --
> > > > To unsubscribe:
<mailto:[EMAIL PROTECTED]>
> > > > For additional commands:
<mailto:[EMAIL PROTECTED]>
> > > > Troubles with the list:
<mailto:[EMAIL PROTECTED]>
> > >
> > > --
> > > To unsubscribe:   <mailto:[EMAIL PROTECTED]>
> > > For additional commands: <mailto:[EMAIL PROTECTED]>
> > > Troubles with the list: <mailto:[EMAIL PROTECTED]>
> > >
> > >
> >
> >
> > --
> > To unsubscribe:   <mailto:[EMAIL PROTECTED]>
> > For additional commands: <mailto:[EMAIL PROTECTED]>
> > Troubles with the list: <mailto:[EMAIL PROTECTED]>
> >
> > --
> > To unsubscribe:   <mailto:[EMAIL PROTECTED]>
> > For additional commands: <mailto:[EMAIL PROTECTED]>
> > Troubles with the list: <mailto:[EMAIL PROTECTED]>
> >
> >
>
>
> --
> To unsubscribe:   <mailto:[EMAIL PROTECTED]>
> For additional commands: <mailto:[EMAIL PROTECTED]>
> Troubles with the list: <mailto:[EMAIL PROTECTED]>
>
> --
> To unsubscribe:   <mailto:[EMAIL PROTECTED]>
> For additional commands: <mailto:[EMAIL PROTECTED]>
> Troubles with the list: <mailto:[EMAIL PROTECTED]>
>
>


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

Reply via email to