> -----Original Message-----
> From: Research labs [mailto:[EMAIL PROTECTED]
> Sent: Monday, August 02, 2004 1:23 PM
> To: Struts Users Mailing List
> Subject: RE: DaTASOURCE CREATION AT USER LOGIN TIME...Newbie
> 
> 
> Jim,
> 
> Thanks for your response. 
> I want each user to login to the database(MySQL), via
> a JSP.  Once logged in, I want them to use their
> database username (specified at log in time) for
> communicating with the database throught their
> session.  To put it another way, if 4 users are
> currently logged in (via a JSP etc.), When I query the
> data dictionary of the database, I want their names to
> come up.  At any point in time, I want to be able to
> find out, who is logged in, this is why I do not want
> everyone to log in with the same username and password
> e.g. ola/ola-hardcoded in the Struts config's
> data-source.

Okay... well this isn't an easy solution to be 100% right about.  Mostly becuase users 
can simply close their browser, leaving themselves logged in until their session times 
out.  Which means they'll have a connection open to the database.... not exactly a 
performance booster.

What you could do, and I believe is a standard practice, is to put in the application 
scope a hash table/list of usernames that have logged in, and use an 
HttpSessinListener to remove users from the hash table/list as they log off or are 
to'd.  You can even persist this to a db table if you wanted, rather then pt it into 
application scope.

That would pretty much achieve your objective of knowing who is logged in at any 
moment.  Use a hash table with the userid as the key, and in the value you can keep 
track of last acitivity, current sessionId and other nice to know bits as well.


> 
> I do not mind using any datasource so long as I can
> achieve my objective.
> 
> Thanks.
> Ola.
> 
>  --- Jim Barrows <[EMAIL PROTECTED]> wrote: 
> > 
> > 
> > > -----Original Message-----
> > > From: Research labs
> > [mailto:[EMAIL PROTECTED]
> > > Sent: Monday, August 02, 2004 12:15 PM
> > > To: Struts Users Mailing List
> > > Subject: DaTASOURCE CREATION AT USER LOGIN
> > TIME...Newbie
> > > 
> > > 
> > > Hello,
> > > 
> > > Can anyone please tell me how to specify the
> > username
> > > and password for "<data-source" at the time a user
> > > logs in, instead of hard coding as "ola" is
> > hardcoded
> > > below:
> > >  
> > >   <data-sources>
> > >    <data-source
> > > type="org.apache.commons.dbcp.BasicDataSource">
> > >      <set-property property="driverClassName"
> > > value="com.mysql.jdbc.Driver" />
> > >      <set-property property="url"
> > > value="jdbc:mysql://localhost/cargo" />
> > >      <set-property property="username" value="ola"
> > />
> > >      <set-property property="password" value="ola"
> > />
> > >    </data-source>
> > >   </data-sources>
> > > 
> > > If this is not possible, can you please tell an
> > > alternative way of achieving this.
> > 
> > I think you're deep into containter dependency here.
> >  Not sure what you're needs are for a dynamic login
> > it to the database, you could also look at providing
> > the informaiton through Ant, or other build tool.
> > 
> > 
> 
> Thanks for your response. 
> I want each user to login to the database(MySQL), via
> a JSP.  Once logged in, I want them to use their
> database username (specified at log in time) for
> communicating with the database throught their
> session.  To put it another way, if 4 users are
> currently logged in (via a JSP etc.), When I query the
> data dictionary of the database, I want their names to
> come up.  At any point in time, I want to be able to
> find out, who is logged in, this is why I do not want
> everyone to log in with the same username and password
> e.g. ola/ola-hardcoded in the Struts config's
> data-source.
> 
> I do not mind using any datasource so long as I can
> achieve my objective.
> 
> Thanks.
> Ola.
> 
> 
> > > 
> > > Thanks.
> > > 
> > > Ola.
> > > 
> > > 
> > >   
> > >   
> > >           
> > >
> >
> ___________________________________________________________ALL
> > > -NEW Yahoo! Messenger - all new features - even
> > more fun!  
> > http://uk.messenger.yahoo.com
> > 
> >
> ---------------------------------------------------------------------
> > To unsubscribe, e-mail:
> > [EMAIL PROTECTED]
> > For additional commands, e-mail:
> > [EMAIL PROTECTED]
> > 
> > 
> >
> ---------------------------------------------------------------------
> > To unsubscribe, e-mail:
> > [EMAIL PROTECTED]
> > For additional commands, e-mail:
> > [EMAIL PROTECTED]
> > 
> >  
> 
> 
>       
>       
>               
> ___________________________________________________________ALL
> -NEW Yahoo! Messenger - all new features - even more fun!  
http://uk.messenger.yahoo.com

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to