Servlet Registration Form with MySQL Database Example

Here you will get servlet registration form with mysql database example.

This simple registration form include three fields, full name, email and password. If you want you can add more fields.

Servlet Registration Form with MySQL Database Example

MySQL Database

As here we are using mysql database so create a database with name db.

Now create a table with name user having three fieldsĀ fname, email and pass of varchar type.

Servlet Registration Form with MySQL Database Example

Java Project

Create a dynamic web project and add following files in it.

WebContent/index.html

It contains a registration form with fields like full name, email and address. When you fill the form and submit it the request is sent to server for further processing.

src/com/RegisterServlet.java

This servlet is responsible for fetching the registration details and then saving them in database.

WebContent/success.html

The response goes to this page if user is successfully registered.

WebContent/error.html

The response goes to this page if any error is occurred.

Save and run your project.

Servlet Registration Form with MySQL Database Example

Comment below if you are facing any problem regarding above servlet registration form example.

2 comments

  • utkarsh rai

    Hey! not given how to connect the ragestrationservelet.java file to the html file and not any xml file how can it be possible please tell me !

    Reply
    • Admin

      When form is submitted the request in sent to RegisterServlet.java. You can see the action attribute in register form, it contains name of servlet that will handle the request.

      Reply

Leave a Reply

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