aspose file tools*
The moose likes Servlets and the fly likes Form-based authentication - check db connection Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Form-based authentication - check db connection" Watch "Form-based authentication - check db connection" New topic
Author

Form-based authentication - check db connection

Viv Singh
Ranch Hand

Joined: Nov 08, 2008
Posts: 73
Hey,

(I am not sure if this is the section in the forum to ask the question).

I have a web application that is based on form-based authentication where the userdetails and roles are stored in a database.

I was wondering whether it is possible e.g. in case the database server is not started to show a message on the login page saying that there is no connection to the database.

at the moment, if i try to login to the web app and the database is not started a few exceptions get thrown which can be seen in the log file.
is there a way to check if there is a connection established to the db?

thanks in advance
Alan Mehio
Ranch Hand

Joined: Apr 04, 2005
Posts: 73
Hi,
During the login process ( login Servlet code); make a class name DBConnectionChecker which has one method
in the method try to connect to the database as below so if the method returns false, you redirect to the login page with an error message set in the request attribute so that you can display it on the view layer( jsp or whatever is you view layer)




Regards,
Alan Mehio
London,UK


Regards,
Alan Mehio
London, UK
Viv Singh
Ranch Hand

Joined: Nov 08, 2008
Posts: 73
Hi,

thanks for the reply.
The thing is I dont have me custom-made login servlet.

Bosun Bello
Ranch Hand

Joined: Nov 06, 2000
Posts: 1510
That is likely a limitation of using an already implemented authentication mechanism like form-based authentication. You can only forward to the designated error page. But not able to actually customize how it displays different errors that occur.


Bosun (SCJP, SCWCD)
So much trouble in the world -- Bob Marley
 
wood burning stoves
 
subject: Form-based authentication - check db connection