This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
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


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Form-based authentication - check db connection
 
Similar Threads
Advice on form-authentication
Authentication using Java
Form Based Authentication
Authenication of a web resource
Secure and Non Secure