are there not this lifecycle listeners for sessions (=HttpSessionListener?)?  if
so try to use it.

Peter

Brian Moynihan wrote:

> Anyone know how to the database connection when the session terminates, say
> after 10 minutes of inactivity?
>
> Thanks for your help on maintaining a db connection between servlets using
> the session attribute
>
> Brian.
>
> -----Original Message-----
> From: Garcia Buendia, Carlos [mailto:[EMAIL PROTECTED]]
> Sent: Tuesday, January 08, 2002 9:32 AM
> To: [EMAIL PROTECTED]
> Subject: Re: Can Database connection be maintained between servlets ...
>
> You can use the session object to share the database connection between
> servlets.
>
> After verifying username and password, in the session object you put the
> database connection:
>
>                 //Get the session
>                 HttpSession mySession = req.getSession(true);
>                 //Set the database connection as a session attribute
>                 mySession.setAttribute("DBConn", con);
>
> 'con' is the Connection object
>
> Each servlet that wanted to use that connection must get the connection
> object from the session:
>
>                 // Get the session
>                 HttpSession session = req.getSession(true);
>
>                 //Get the connection object from the session
>                 Connection con = (Connection)session.getAttribute("DBConn");
>
> >
> >Hi there,
> >
> >Does anyone know how to maintain a database connection between
> >servlets:
> >
> >i.e. Open the connection through a login servlet which gives
> >the database
> >username and password. What we need, is for all other servlets in the
> >application to have access to this connection.
> >
> >A possible workaround would be passing the username and
> >password and opening
> >the connection in each individual servlet, but this I presume
> >would not be
> >very efficient in terms of speed with each servlet opening and
> >closing the
> >database connection.
> >
> >Any help or direction would be appreciated,
> >Brian.
> >
> >
> >**********************************************************************
> >Privileged, confidential and/or copyright information may be contained
> >in this e-mail. This e-mail is for the use only of the intended
> >addressee. If you are not the intended addressee, or the person
> >responsible for delivering it to the intended addressee, you may not
> >copy, forward, disclose or otherwise use it or any part of it in any
> >way whatsoever. To do so is prohibited and may be unlawful.
> >
> >If you receive this e-mail by mistake please advise the sender
> >immediately by using the reply facility in your e-mail software.
> >
> >Orygen (Ireland) Limited may monitor the content of e-mails sent and
> >received via its network for the purposes of ensuring compliance with
> >its policies and procedures.
> >
> >This message is subject to and does not create or vary any contractual
> >relationship between Orygen (Ireland) Limited and you.
> >**********************************************************************
> >
> >_______________________________________________________________
> >____________
> >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
>
> **********************************************************************
> Privileged, confidential and/or copyright information may be contained
> in this e-mail. This e-mail is for the use only of the intended
> addressee. If you are not the intended addressee, or the person
> responsible for delivering it to the intended addressee, you may not
> copy, forward, disclose or otherwise use it or any part of it in any
> way whatsoever. To do so is prohibited and may be unlawful.
>
> If you receive this e-mail by mistake please advise the sender
> immediately by using the reply facility in your e-mail software.
>
> Orygen (Ireland) Limited may monitor the content of e-mails sent and
> received via its network for the purposes of ensuring compliance with
> its policies and procedures.
>
> This message is subject to and does not create or vary any contractual
> relationship between Orygen (Ireland) Limited and you.
> **********************************************************************
>
> ___________________________________________________________________________
> 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

--

Peter Huber
(IT Consultant)

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

evodion Information Technologies
GmbH & Co KG
Gesch�ftsstelle M�nchen
Witneystr.1
D-82008 Unterhaching
Telefon: +49-89-66561 - 128
Fax:     +49-89-66561 - 199
e-mail: mailto:[EMAIL PROTECTED]
Germany Web: http://www.evodion.de

___________________________________________________________________________
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