This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
(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?
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)
Joined: Nov 08, 2008
thanks for the reply.
The thing is I dont have me custom-made login servlet.
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