fund transfer module for online banking in jsp
843838Apr 7 2007 — edited Mar 9 2008i am working on safe and secured internet banking project . currently working on fund transfer module. any particular user can transfer money from his/her account to any account.my first jsp file for this is:- fundtrans.jsp
in this jsp page there are 2 comboboxes :- from account and to account , i m getting accounts in these comboboxes from database.in my case i m using saving table where all information about user's saving account is placed.
fundtrans.jsp:-
<%@ page import="java.util.*, java.lang.*, java.sql.*" %>
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<table width="1024" border="0" cellpadding="0" cellspacing="0">
<!--DWLayoutTable-->
<tr>
<td width="119" height="164"></td>
<td width="152"></td>
<td width="162"></td>
<td width="147"></td>
<td width="444"></td>
</tr>
<tr>
<td height="32"></td>
<td valign="top">From Account</td>
<td></td>
<td valign="top">
<form name="form1" method="post" action="">
<label>
// combobox 1 which gets account_no from database from which transfer to be made
<select name="select2">
<%
// code for getting account_no from database table saving
try {
Class.forName("com.mysql.jdbc.Driver").newInstance();
Connection con = DriverManager.getConnection("jdbc:mysql://mridul:3306/bank","root" ,"root");
PreparedStatement ps;
Statement st=con.createStatement();
ResultSet rs = st.executeQuery("select * from saving where saving.username = '" + session.getAttribute( "theName" ) + "'");
%>
<%
while(rs.next())
{
String Account =rs.getString("account_no"); %>
<option value=""> <%= Account %> </option>
<%}%>
<%
rs.close();
st.close();
con.close();
}%><%
catch(Exception e)
{
e.printStackTrace();
}
%>
</select>
</label>
</form> </td>
<td></td>
</tr>
<tr>
<td height="81"></td>
<td> </td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td height="34"></td>
<td valign="top">To Account </td>
<td></td>
<td valign="top"><form name="form2" method="post" action="">
<label>
// combobox 2 which gets account_no from database to which transfer is made
<select name="select">
<%
//this gets account_no from database table saving and placed in combobox
try {
Class.forName("com.mysql.jdbc.Driver").newInstance();
Connection con = DriverManager.getConnection("jdbc:mysql://mridul:3306/bank","root" ,"root");
Statement st=con.createStatement();
PreparedStatement ps1 = con.prepareStatement("select distinct account_no from saving");
ResultSet rs=ps1.executeQuery();
System.out.println("SECOND Succesfully Executed");
%>
<%
while(rs.next())
{
String Accountno = rs.getString("account_no"); %>
<option value=""> <%=Accountno %> </option>
<%}%>
<%
rs.close();
st.close();
con.close();
}%><%
catch(Exception e)
{
e.printStackTrace();
}
%>
</select>
</label>
</form> </td>
<td></td>
</tr>
<tr>
<td height="52"></td>
<td> </td>
<td></td>
<td></td>
<td></td>
</tr>
<tr>
<td height="34"></td>
<td valign="top">Amount</td>
<td></td>
<td valign="top"><form name="form3" method="post" action="">
<label>
// this is text box in which user gives amount to be transfered
<input type="text" name="bal">
</label>
</form> </td>
<td></td>
</tr>
<tr>
<td height="83"></td>
<td> </td>
<td> </td>
<td></td>
<td></td>
</tr>
<tr>
<td height="37"></td>
<td> </td>
//this is a submitt type button which goes to the update.jsp for further processing
<td valign="top"><form name="form4" method="post" action="update.jsp">
<label>
<input type="submit" name="b4" value="continue">
</label>
</form>
</td>
<td></td>
<td></td>
</tr>
<tr>
<td height="467"></td>
<td> </td>
<td> </td>
<td></td>
<td></td>
</tr>
</table>
</body>
</html>
update.jsp:- in this file i wrote sql query for fund transfer. in this i m subtracting balance from one account_no and want to show updated saving table. i m not using query for addition of balance in another account_no becoz i m getting problem here.
<%@ page import="java.util.*, java.lang.*, java.sql.*" %>
<%
String name,pwd;
boolean found=false;
String acc= request.getParameter("select2");
String acc1= request.getParameter("select");
String ammount= request.getParameter("bal");
Integer ammount1 = Integer.valueOf((String)session.getAttribute("bal"));
//Establish connection
try
{
Class.forName("com.mysql.jdbc.Driver").newInstance();
Connection con = DriverManager.getConnection("jdbc:mysql://mridul:3306/bank","root" ,"root");
Statement st=con.createStatement();
// ResultSet rs = st.executeQuery("update saving set balance = balance-ammount1 where saving.account_no = '" + acc +"'");
ResultSet rs = st.executeQuery("select * from saving");
while ( rs.next() ) {%>
<tr>
<td valign="top" height="43"><%=rs.getString(1) %></td>
<td valign="top"> <%=rs.getString(2) %></td>
<td valign="top"> <%= rs.getString(3) %></td>
<td valign="top"> <%=rs.getString(4) %></td>
<td valign="top"> <%=rs.getString(5) %></td>
<td></td>
</tr>
<%}
rs.close();
st.close();
con.close();
}
catch(Exception e)
{
e.printStackTrace();
}
%>
my prob is i m not able to print updated saving table i found 1 blank page or sometimes i find "sever is not capable for fulfilling the request". i m able to understand that whether my sql query is wrong or i m getting value from combobox via request.getParameter. please help me as soon as possible.