We had done connection pooling for our application in a way as explained below:

We have a servlet which starts up with the web server and among other things, it
does maintain static references to commonly used resources, and in specific an
object which does connection pooling.

We did not use the session here, but made data members static.  We guarenteed that
the resources would be correctly initialized at start up time though.

Next, even if I want to do some thing like sharing a database connection, I would
not use session.putValue() which limits the same to only the session, but would use

servletConfig.getServletContext().setAttribute ("CartFactory",cFactory);

I for instance use such a mechanism to set a class factory when the web server
starts up - its tied with the servlet context and not to the session.  This would
really mean sharing a common resource across a web server.

I am not sure if jsdk2.0 supports setAttribute() on servletcontext though.

Finally,  SingleThreadedModel is to be used if and only if you want a new Login
Servlet for every invocation of it - which means that there is something very
specific to each instance of the Login Servlet.

As far as I see, there can be nothing very specific to a servlet - user specifics
go into the session and not to the servlets.  Usage of Login Servlets to something
as generic as Login Servlet would be a wastage of resources - a new Servlet
instantiated and loaded into memory every time it is invoked.  Correct me if I am
wrong.


Anand

"Subrahmanyam A.V.B." wrote:

> > Heres wut I am trying to do
> >
> > Login.html--->create session--->pass username,pwd to Login Servlet---->Login
> > Servlet instantiates my DbCOnnection Object---->Then redirects to Query.Jsp
> >
> > Just a note that we are not going to be Connection pooling.
> >
> > Can I pass the DbConnection Object through the session.putValue ?? Also does
> > my login servlet has to implement SingleThreadModel??
> >
>
> This is not a good practice. Contents of sessions should be
> serializable, and connections are not. Imagine a distributed servlet/jsp
> cluster!
>
> Regards,
>
> Subrahmanyam
> -----------------------------------------------------------------------------
> Subrahmanyam A.V.B.
> http://www.Subrahmanyam.com
>
> ===========================================================================
> To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
> FAQs on JSP can be found at:
>  http://java.sun.com/products/jsp/faq.html
>  http://www.esperanto.org.nz/jsp/jspfaq.html

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
FAQs on JSP can be found at:
 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.html

Reply via email to