I am designing a small app that accepts a DB username and password, connects to an Oracle database, accepts a record, and puts it into the database, using servlets.
I have one servlet which accepts the username and password, makes the DB connection and then redirects to another page. On this page, the record values are accepted. Here, I want to insert into the DB, but I don't have the connection object. Is there some way I can pass the connection object to this new servlet?
Or should I use a different approach, like authenticate the username and password, save them using setAttribute and then make the connection in the second servlet?
I am completely new to web programming and servlets, so any help would be great, thanks!
ServletContextas an attribute. It will be visible to every servlet .ContextListener. Create a connection there. Store the connection in ServletContext attributes.