Javatpoint Logo

91-9990449935

 0120-4256464

Example of Registration form in servlet

Here, you will learn that how to create simple registration form in servlet. We are using oracle10g database. So you need to create a table first as given below:

To create the registration page in servlet, we can separate the database logic from the servlet. But here, we are mixing the database logic in the servlet only for simplicity of the program. We will develop this page in JSP following DAO, DTO and Singleton design pattern later.


Example of Registration form in servlet

In this example, we have created the three pages.

  • register.html
  • Register.java
  • web.xml

register.html

In this page, we have getting input from the user using text fields and combobox. The information entered by the user is forwarded to Register servlet, which is responsible to store the data into the database.


Register.java

This servlet class receives all the data entered by user and stores it into the database. Here, we are performing the database logic. But you may separate it, which will be better for the web application.


web.xml file

The is the configuration file, providing information about the servlet.



To connect java application with the Oracle database ojdbc14.jar file is required to be loaded. Put this jar file in WEB-INF/lib folder.