Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Form-based authentication - check db connection

 
Viv Singh
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Viv Singh
Ranch Hand
Posts: 73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

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

 
Bosun Bello
Ranch Hand
Posts: 1510
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic