pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: J. <sweepingoar@yahoo.com>
To: pgsql-jdbc@postgresql.org
Subject: Re: connection pooling with servlets
Date: Thu, 27 Apr 2006 23:11:05 -0700 (PDT)
Message-ID: <20060428061105.37423.qmail@web54215.mail.yahoo.com> (raw)
In-Reply-To: <4451A813.6030403@vailsys.com>

Thanks.  I posted some of the relevant code here;
  
  http://saloon.javaranch.com/cgi-bin/ubb/ultimatebb.cgi?ubb=get_topic&f=7&t=016798
  
  But I'm still baffled as to how to get access to a session in a servlet  that was called by a jsp.  Should servlets have access to sessions  easily?  Everyone is making it seem like this shouldn't be a  problem, but then I've read in other places that a jsp calling a  servlet clears whatever attributes were part of the request object.

David Durham <ddurham@vailsys.com> wrote:  J. wrote:
> Thanks for replying.  I'm not sure if that would help, but maybe if I 
> understand the suggestion better it will.
> 
> Right now I've got the index.jsp calling Login servlet via POST.  Then 
> Login creates the connection, puts it into a session with some other 
> attributes and forward(req,res) to welcome.jsp.  

Not  much point in storing a datasource as a session attribute (1 datasource  per application user?). More appropriate to make it application-wide by  putting a datasource in a servlet context or, as someone else  suggested, a static attribute/property/member/variable ...  request.getSession().getServletContext().setAttribute(...). JNDI is  another good place to put this sort of thing. An easy way to make sure  your datasource is always available is to use a servlet context  listener to create it when the application is initialized. Google for  servlet context lifecycle should tell you how to do setup a listener.

Now,  as for a null pointer on your connection object, maybe you have  something misconfigured in your datasource. Username, password, host,  and driver class are usual suspects.


> Welcome.jsp has a form 
> that uses GET to call a Search servlet and this is where I get a null 
> pointer on the connection object.  I'm trying to get the session out of 
> the request object, but it seems like the request loses state by the 
> time I'm getting to it (in Search servlet).

Not sure.  You can post your code and maybe get some help.  Wait, is this homework?


-Dave



		
---------------------------------
Yahoo! Messenger with Voice. Make PC-to-Phone Calls to the US (and 30+ countries) for 2ยข/min or less.

view thread (8+ messages)  latest in thread

Message-ID: <20060428061105.37423.qmail@web54215.mail.yahoo.com>
Permalink:  ../20060428061105.37423.qmail@web54215.mail.yahoo.com/
Also on:    postgresql.org/message-id/20060428061105.37423.qmail@web54215.mail.yahoo.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-jdbc@postgresql.org
  Cc: sweepingoar@yahoo.com
  Subject: Re: connection pooling with servlets
  In-Reply-To: <20060428061105.37423.qmail@web54215.mail.yahoo.com>
  References: <4451A813.6030403@vailsys.com> <20060428061105.37423.qmail@web54215.mail.yahoo.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox