How to Design a Login Page Using Jsp
Registration and Login tutorial using jsp & servlet - part 1
Hello, friends welcome again to TechTutorial. Today post we will learn a complete login and registration system using JSP & Servlet. In this post, we will design our Registration Page and then we will code for backend or serverside. So no more intro lets start our work.
Prerequisite
1.Netbeans IDE.
2.Apache Tomcat 8.5
3.MySQL Workbench
4.MySQL Connector Java 8.0
5.Basic Knowledge of Java Class, Servlet.
6.Image for our project.
Step-1:
This is the basic setup of our project. that will help us to better understanding what we are doing.
-Open your Netbeans IDE and create a new project.
-Expand your project, right-click of the Web Pages folder create to new folder name is css and img folder.
-Again right-click of the Web Pages folder the create two JSP page name index.jsp and register.jsp
- If Netbeans doesn't create a web.xml file then right-click of the WEB-INF page>New>Other>web.xml to create a new web.xml file.
- Create a style.css file in the css folder as like as we created our web.xml file.
-Paste all of our required photos to theimg folder.
-Now create a package for our Web Project. Right-click of the Sources Packages folder New> Java Package> package name and click finish.
-Right-click Librariesfolder>Add JAR/Folder then select themysql-connector-java-8.0.18.jar file
Step-2:
In this part, we will design our Registration form in the registration.jsp page then copies the below code and paste.
Step-3:
This step we will CSS code for our form. Open style.css file from thecss folder. Then copies the CSS Code from below and paste it to your style.css file.
Step-4:
Now we will create a database to store our user data. so open your MySQL Workbench application and create a new database and give the namejsp_project .
-then create a user table with 4 columns which are (id primary key autoincrement, name, email unique, password)
follow the picture
MySQL Database Table |
Step-5 :
Now its time to code for server site. Now follow the step below.
1. Create a User Model java class. expand your Source Packages folder right-click your package>new>java class> name it User. Now click finish. then copies the below code and paste it your User.java file.
*don't forget to change your package name.
User.java
2. Create a connection class that will be used to connecting with our MySQL database.
*don't forget to change this part (test","root","almamun@123") with your database name, username, and password.
ConnectionPro.java
3. Now we will create a query class that will help us to handle the database. I mean insert data to the database, find user data from the database. I name it UserDatabase.
*don't forget to change your package name.
UserDatabase.java
4. Create a servlet name is RegisterServlet. we mention it in our register.jsp page form action.
on the servlet, creation time don't forget to deploy it in web.xml file. compies the below code and paste it to the section.
RegisterServlet.java
I hope you follow the steps properly. And it's working correctly. If you learned from here please like the post, share the post, and comment in the post if you have any questions.
How to Design a Login Page Using Jsp
Source: https://www.techtutorial.cn/2020/01/login-and-registration-using-JSP-Servlet-and-MySQL-Database.html
0 Response to "How to Design a Login Page Using Jsp"
Post a Comment