Jsp

Registation form in Servlet Jsp

In tutorials will teach banking registration form in jsp servlet using use bean class for the right way to do the java web development.

First step design the Registration form

Form Registration

<html>
<head>
<title>Online Banking with Earnest </title>
</head>

<body bgcolor=pink>
<br>
<br>
<center>
<u>
 <h1> NDB Bank New User Registration </h1>
 <h3> ( Servlet application )  </h3>
</u>

<form  method=post action="Bank.jsp">
<table border=2 bordercolor=black width=40%>

<tr>
 <td>First Name:</td>
 <td> <input type=text name="fname" size=25></td>
</tr>

<tr>
 <td>Last Name:</td>
 <td><input type=text name="lname" size=25></td>
</tr>

<tr>
 <td>Address:</td>
 <td><input type=text name="address" size=25></td>
</tr>
  
<tr>
 <td>Account Type:</td>
 <td><input type=text name="account" size=25></td>
</tr>  

<tr>
 <td>Annual Income:</td>
 <td><input type=text name="income" size=25></td>
</tr>  

<tr>
 <td>Phone Number:</td>
 <td><input type=text name="phone" size=25></td>
</tr> 

<tr><td>
 <center><input type=SUBMIT value="Register"></center><td>
</tr> 
</table>
</form>
</center>
</body>
</html>

Create the package account inside the package create the class BankAcc.java

BankAcc.java

package account;


import java.io.*;
import java.sql.*;

public class BankAcc {
    
 private String fname="";
 private String lname="";
 private String address="";
 private String account="";
 private String income="";
 private String phone="";
 private String regno="";

 Connection con=null;
 PreparedStatement stat=null;

 public void setFname(String fname) {this.fname=fname;}
 public String getFname() {return fname;}

 public void setLname(String lname) {this.lname=lname;}
 public String getLname() {return lname;}

 public void setAddress(String address) {this.address=address;}
 public String getAddress() {return address;}

 public BankAcc() throws ClassNotFoundException
 {
   Class.forName("com.mysql.jdbc.Driver");
            
 }

 public boolean save()
 {
  boolean sucess=false;

  try
  {
   con = DriverManager.getConnection("jdbc:mysql://localhost/nbank","root","");
   stat = con.prepareStatement("insert into registation(firstname,lastname,phone)values(?,?,?)");
   stat.setString(1,getFname());
   stat.setString(2,getLname());
   stat.setString(3,getAddress());

   int status=stat.executeUpdate();

   if(!(status==0))
   {
    stat=con.prepareStatement("select max(id) from registation");
    ResultSet rs1=stat.executeQuery();
    rs1.next();
    regno=rs1.getString(1);
    sucess=true;
   }
  }
   catch(Exception e1)
   {
    System.out.println(e1.toString());
   }
   finally
   {
    try
    {
     con.close();
    }
    catch(Exception e2){}
    return sucess;
   }

        }
   public String getRegno()
   {
    return regno;
   }
 }

Create the bank.jsp page

bank.jsp

At the above you have add the usebean 

<jsp:useBean id=”bank1″ scope=”page” class=”account.BankAcc”/>

<jsp:setProperty name=”bank1″ >

<jsp:useBean id="bank1" scope="page" class="account.BankAcc"/>
<jsp:setProperty name="bank1" >

i have attached the video link below. which will do this tutorials step by step

 

admin

Recent Posts

Laravel 11 CRUD Mastering RESTful API MVC with Repository Pattern

In this tutorial will teach Laravel 11 Api MVC with Repository Pattern Crud Application step…

3 days ago

Laravel 11 CRUD Application

In this tutorial will teach Laravel 11 CRUD Application step by step. Laravel  11 CRUD…

4 weeks ago

How to make Times Table in React

in this tutorials we will be talk about how to make a times table in…

1 month ago

Laravel Tutorial: How to Add Numbers Easily Laravel 10

In this tutorials will teach How to add two numbers in Laravel 10. (more…)

1 month ago

Build 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 Node.js,…

2 months ago

Hospital Management System using OOP Java and MySQL

In this tutorial, we will explin you through the process of building a Hospital Management…

3 months ago