[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 550
  • Last Modified:

How tu use a login screen using a servlet and then verify the user info in the DB

I have a html page who gives the user  two options to click on, I want to use a login screen and a verify that information in my table from a DB. These two servlets are protected for the same session, so I want to share the DB connection.How to proceed?
Thank you
0
Mimi1979
Asked:
Mimi1979
1 Solution
 
ebertkCommented:
Best option is to create one Servlet that handles both requests.  You can the use the single DB connection for both without much trouble.

Option two is to have your DB connection use static varriables so that it is available to any instance of a particular class.  You could then create a single class that handles database connections.  Any new class that creates an instance of this class would then have database connection (as long as the first instance created sucessfully connects to the database)
0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now