Requirement

  • Create a Login page to enter user name and password
  • On submit, validate the user name / password against MySQL database
  • If the authentication is successful, forward to home page showing welcome message along with the user name
  • If the authentication fails, return back to the login page with appropriate error message.
  • If there is exception / errors during authentication process return back to login page with appropriate error message.

Pre-requisites

  • MySQL and Tomcat is already installed
  • You have basic knowledge of MySQL to create tables and insert / update records
  • You have basic knowledge of Java and J2EE web applications
  • Have your favorite IDE for developing / reviewing code.

Concepts Covered

  • JDBC connectivity to MySQL from Servlet
  • Simple application of JSTL tag
  • Using session variable in Servlet
  • Polymorphism concept using JDBC
  • Basic error handling concepts

NOTE: Don't even think of using the code as is for a production environment
This is just for education purpose but you can take inspiration from this code.


Checkout our similar article on simple login application using Struts 2 Framework

No comments

Leave your comment

In reply to Some User
We use cookies

We use cookies on our website. Some of them are essential for the operation of the site, while others help us to improve this site and the user experience (tracking cookies). You can decide for yourself whether you want to allow cookies or not. Please note that if you reject them, you may not be able to use all the functionalities of the site.