Hi Shwetabh:

I guess i dont quite understand why you need a connection to display a login
screen. The reason I would be wary of using connections created in the init()
method is that that connection is then created exactly once when the servlet is
initialised and it seems to me that you are using that *same* connection for all
users (you are probably declaring it as a static variable?). I repeat: code in the
init() method is *not* executed once for each user, but *exactly* once after the
servlet is initialised. This must tie into why when you restart the server your
problem seems to go away: because when you restart the server, the init() is
executed.

So my question to you is this: why do you need to create a connection at all in the
init()? Also I dont think you may want to display a login screen from the init()
method. What may be more common/logical I think is the following set of steps:

1. Create a connection pool in the init();
2. Create a login.jsp and in the doGet() redirect to a login page, say login.jsp
(or more simply, in the doGet() method write code to display a login screen. Then
of course, when the url http://yourserver/yourServlet is entered, a login screen
will be displayed.)
3. When the user fills in the login data, get a connection from the pool, contact
the database and check if the user is valid. If so, then get the url that you have
to display (from more queries to the database? (but using the same connection)) and
display it (either directly in doPost or by redirecting to another jsp). If not,
send the user to an invalidUser.jsp page.

Hope I havent misunderstood something basic to your needs.
Geeta

___________________________________________________________________________
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