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:

CREATE TABLE  "REGISTERUSER"   
   (    "NAME" VARCHAR2(4000),   
    "PASS" VARCHAR2(4000),   
    "EMAIL" VARCHAR2(4000),   
    "COUNTRY" VARCHAR2(4000)  
   )  
/

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.