Home Jsp Registation Form Jsp Servlet Mysql Maven

Registation Form Jsp Servlet Mysql Maven

8 min read

This tutorial will teach you how to make Registation form Jsp Servlet Mysql Maven step by step.we have created the file index.jsp.

First Step :  Open Eclipse IDE  Create a New Project -> File -> New->Dynamic Web Project

After Select  Dynamic Web Project you will have a screen like this

Type the Project Name Click Finish. After that select the Project and right click you will have a screen shown below.
Configure->Convert to Maven Project.

After Selected.you will have a screen like this.

Click Finish.After that.

Add a new Dependency

You will add the Mysql Connector here .Enter groupId,artifactid or sha1 prefix or pattern textbox type the Dependency name Mysql Connector. you can get the result on the search result below.

Select the Mysql Connector Click Ok Button.

After that create the index,jsp File.

Paste the Code Inside the index,jsp


<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0-beta2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-BmbxuPwQa2lc/FVzBcNJ7UAyJxM6wuqIj61tLrc4wSX0szH/Ev+nYRRuWlolflfl" crossorigin="anonymous">
<body bgcolor="#fffff" >
<form method="post" action="addServlet">
<table width= 500px cellpadding ="2" cellspacing = "2" align ="center" border ="1" bordercolor ="#FF69B4"
 bgcolor ="#E6E6FA">

	<td align ="center" colspan = "2"><font color ="#0000F"><h2>Student Information</h2></font></td>

	<td align ="center"><b>Student Name</td>
	<td><input type="text" size="20"  name="sname"></td>	

	<td align ="center" valign ="top"><b>Course<b></td>
	<td><select name="course">
        <option value="Vb.net">Vb.net</option>
        <option value="Enterprise Java">Enterprise Java</option>
        <option value="Core Java">Core Java</option>

	<td align ="center" valign="top"><b>Address<b></td>
	<td><input type=text name="address"></textarea>

	<td align ="center"><b>Moblie No<b></td>
	<td><input type="text" size="20" maxlength="10"  name="mno"></td>		


	<td align ="center">&nbsp;</td>
	<td><input type="submit" value="Register" /></td>		


After that Create the Servlet File which name is addServlet  

Paste the Code

import java.io.IOException;
import java.io.PrintWriter;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.Statement;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class addServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		PreparedStatement st1=null;
        Connection con; 
        PrintWriter out = response.getWriter();

		 String  sname =request.getParameter("sname");
		 String  course =request.getParameter("course");
		 String addr =request.getParameter("address");
		 String mobile =request.getParameter("mno");
        con = DriverManager.getConnection("jdbc:mysql://localhost/lblschool", "root","");	
		String query ="insert into student(sname,course,address,mno)values(?,?,?,?)";
		st1= con.prepareStatement(query);

		st1.setString(1, sname);
		st1.setString(2, course);
		st1.setString(3, addr);
		st1.setString(4, mobile);
		int k = st1.executeUpdate();

		if(k ==1)
		    out.println("Thanks for registration ......");
			String query2 = "select max(id) from student";
			Statement st2 = con.createStatement();
			ResultSet rs1 = st2.executeQuery( query2);	
			rs1.next( );
			String reg_No = rs1.getString(1);
			out.println("Your registration id is " + reg_No);
		    out.println("Cant' update");
		catch(Exception ee)



I have attached the video tutorial below it will help you  to do this  step by step.










Load More Related Articles
Load More By admin
Load More In Jsp

Leave a Reply

Your email address will not be published. Required fields are marked *

Check Also

Build a Full-Stack Node.js MongoDB CRUD App with JWT Authentication

In this tutorial, we will teach the process of building a full-stack application using Nod…