protected .www.freejavaprojectsonline.blogspot.com . mails to : johnjustin@in.com */
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
import java.sql.*;
import java.util.*;
public class DepositLoan extends HttpServlet{
Connection con;
Statement st;
ResultSet rs;
PreparedStatement ps;
public void doPost(HttpServletRequest req,HttpServletResponse res) throws IOException,ServletException{
try{
int ano=Integer.parseInt(req.getParameter("ANO"));
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con=DriverManager.getConnection("jdbc:odbc:bank");
st=con.createStatement();
res.setContentType("text/html");
PrintWriter out=res.getWriter();
Calendar calendar = new GregorianCalendar();
String date=calendar.get(Calendar.DATE)+"/"+(calendar.get(Calendar.MONTH)+1)+"/"+calendar.get(Calendar.YEAR);
out.println("<html><head><title>Deposits</title>");
out.println("<script language=\"vbscript\">");
out.println(" sub f1");
out.println(" id1.style.visibility=\"visible\"");
out.println(" id2.style.visibility=\"hidden\"");
out.println(" end sub");
out.println(" sub f2");
out.println(" id2.style.visibility=\"visible\"");
out.println(" id1.style.visibility=\"hidden\"");
out.println(" end sub");
out.println(" sub window_onload");
out.println(" f1");
out.println(" end sub");
out.println("</script>");
out.println("</head><body background=\"http:\\\\localhost:8080\\examples\\servlets\\images\\globe.jpg\" link=red alink=green vlink=blue>");
out.println("<h2 align=\"center\"><font color=\"#000080\">");
out.println("<img border=\"0\" src=\"http:\\\\localhost:8080\\examples\\servlets\\images\\earth.gif\" align=\"left\" width=\"50\" height=\"49\">");
out.println("</font></h2><h2 align=\"center\"><font color=\"#000080\">UNIVERSAL NET BANK");
out.println("</font></h2><p align=\"center\"> </p>");
out.println("<table border=\"2\" width=\"100%\" bordercolorlight=\"#0000FF\" bordercolordark=\"#0000FF\">");
out.println("<tr><td width=\"12%\" valign=\"top\" align=\"center\">");
out.println("<a href=\"http:\\\\localhost:8080\\examples\\servlet\\Welcome?ANO="+ano+"\">Welcome");
out.println("</a></td><td width=\"18%\" valign=\"top\" align=\"center\">");
out.println("<a href=\"http:\\\\localhost:8080\\examples\\servlet\\ADetail?ANO="+ano+"\">Account Details");
out.println("</a></td><td width=\"14%\" valign=\"top\" align=\"center\">");
out.println("<a href=\"http:\\\\localhost:8080\\examples\\servlet\\WithDraw?ANO="+ano+"\">Withdrawals");
out.println("</a></td><td width=\"12%\" valign=\"top\" align=\"center\">");
out.println("<a href=\"http:\\\\localhost:8080\\examples\\servlet\\Deposit?ANO="+ano+"\">Deposits");
out.println("</a></td><td width=\"12%\" valign=\"top\" align=\"center\">");
out.println("<a href=\"http:\\\\localhost:8080\\examples\\servlet\\Loan?ANO="+ano+"\">Loans");
out.println("</a></td><td width=\"12%\" valign=\"top\" align=\"center\">");
out.println("<a href=\"http:\\\\localhost:8080\\examples\\servlet\\Option?ANO="+ano+"\">Options");
out.println("</a></td><td width=\"12%\" valign=\"top\" align=\"center\">");
out.println("<a href=\"http:\\\\localhost:8080\\examples\\servlet\\Mail?ANO="+ano+"\">Mail Us");
out.println("</a></td><td width=\"11%\" valign=\"top\" align=\"center\">");
out.println("<a href=\"http:\\\\localhost:8080\\examples\\servlets\\Logout.html\">Logout");
out.println("</a></td></tr></table><table border=\"0\" width=\"100%\">");
out.println("<tr><td width=\"50%\"><font color=\"#000080\"><b>");
out.println("Date : </b></font><font color=\"#000080\"><b>");
out.println(date);
out.println("</b></font></td><td width=\"50%\" align=\"right\"><font color=\"#000080\">");
out.println("<b>Account No : <font size=\"3\">");
out.println(ano);
out.println("</font></b></font></td></tr></table>");
out.println("<p align=\"center\"> <img border=\"0\" src=\"http:\\\\localhost:8080\\examples\\servlets\\images\\deposits.jpg\" width=\"403\" height=\"83\"></p>");
out.println("<p align=\"left\"><b><font color=\"#000080\">");
ps=con.prepareStatement("SELECT LID FROM LTABLE WHERE ACCOUNTNO="+ano+" AND TAMOUNT<>LREPAID");
rs=ps.executeQuery();
if (rs.next()){
rs.close();
rs=ps.executeQuery();
out.println("<table border=\"1\" width=\"75%\">");
out.println("<tr><td width=\"50%\">");
out.println("<input type=\"radio\" value=\"Credit\" checked name=\"R1\" onClick=\"f1\">");
out.println(" <b>Deposit From Credit Card</b></td><td width=\"50%\">");
out.println("<input type=\"radio\" value=\"Account\" name=\"R1\" onClick=\"f2\"><b>Deposit");
out.println(" From Account</b></td></tr></table><p> </p>");
out.println("<div id=\"id1\">");
out.println("<form name=\"Form1\" method=\"POST\" action=\"http:\\\\localhost:8080\\examples\\servlet\\UpDepositLoan\" style=\"position: absolute\">");
out.println("<input type=hidden value=\"Credit\" name=\"TYPE\">");
out.println("<input type=hidden value="+ano+" name=\"ANO\"><center>");
out.println("<table border=\"1\" width=\"75%\" height=\"73\" >");
out.println("<tr><td width=\"50%\" height=\"19\"><b><font color=\"#000080\">Select Loan ID to Deposit</font></b></td>");
out.println("<td width=\"50%\" height=\"19\" colspan=\"2\">");
out.println("<select size=\"1\" name=\"LID\">");
while(rs.next()){
out.println("<option> "+rs.getString(1)+" </option>");
}
out.println("</select></td></tr><tr>");
out.println("<tr><td width=\"50%\" height=\"19\"><b><font color=\"#000080\">Enter the Amount</font></b></td>");
out.println("<td width=\"50%\" height=\"19\" colspan=\"2\"><input type=\"text\" name=\"AMOUNT\" size=\"20\"></td>");
out.println("</tr>");
out.println("<tr><td width=\"50%\" height=\"19\"><font color=\"#000080\">");
out.println("<b>Select The Card Type</b></font></td>");
out.println("<td width=\"50%\" height=\"19\" colspan=\"2\">");
out.println("<select size=\"1\" name=\"CTYPE\">");
out.println(" <option>Visa Card</option>");
out.println(" <option>Master Card</option>");
out.println("</select></td></tr><tr>");
out.println("<td width=\"50%\" height=\"19\"><b><font color=\"#000080\">Enter the Card Number</font></b></td>");
out.println("<td width=\"50%\" height=\"19\" colspan=\"2\"><input type=\"text\" name=\"CNO\" size=\"20\"></td>");
out.println("</tr><tr>");
out.println("<td width=\"50%\" height=\"17\"> </td>");
out.println("<td width=\"25%\" height=\"17\" align=\"right\">");
out.println("<input type=\"submit\" value=\"Submit\" name=\"B1\"></td>");
out.println("<td width=\"25%\" height=\"17\" align=\"right\">");
out.println("<input type=\"reset\" value=\"Reset\" name=\"B2\"></td></tr>");
out.println("</table></center><p> </p>");
out.println("</form></div><div id=\"id2\">");
out.println("<form name=\"Form2\" method=\"POST\" action=\"http://localhost:8080/servlet/UpDepositLoan\">");
out.println("<input type=hidden value=\"Account\" name=\"TYPE\">");
out.println("<input type=hidden value="+ano+" name=\"ANO\"><center>");
out.println("<table border=\"1\" width=\"75%\">");
out.println("<tr><td width=\"50%\"><b><font color=\"#000080\">");
out.println("Loan ID to Deposit</font></b></td><td width=\"50%\" colspan=\"2\">");
out.println("<select size=\"1\" name=\"LID\">");
rs.close();
rs=ps.executeQuery();
while(rs.next()){
out.println("<option> "+rs.getString(1)+" </option>");
}
out.println("<select></td></tr>");
out.println("<tr><td width=\"50%\"><b><font color=\"#000080\">");
out.println("Enter The Amount</font></b></td><td width=\"50%\" colspan=\"2\">");
out.println("<input type=\"text\" name=\"AMOUNT\" size=\"20\"></td></tr>");
out.println("<tr><td width=\"50%\"><b><font color=\"#000080\">");
out.println("Select the Branch</font></b></td>");
out.println("<td width=\"50%\" colspan=\"2\"><select size=\"1\" name=\"BNAME\">");
out.println("<option selected>CHENNAI</option>");
out.println("<option>MUMBAI</option></select></td>");
out.println("</tr><tr><td width=\"50%\"><b><font color=\"#000080\">");
out.println("Select the Account Type</font></b></td>");
out.println("<td width=\"50%\" colspan=\"2\"><select size=\"1\" name=\"ATYPE\">");
out.println("<option selected>SAVINGS</option>");
out.println("<option>CURRENT</option></select></td></tr>");
out.println("<tr><td width=\"50%\"><b><font color=\"#000080\">");
out.println("Account Number To Credit</font></b></td>");
out.println("<td width=\"50%\" colspan=\"2\">");
out.println("<input type=\"text\" name=\"CANO\" size=\"20\"></td>");
out.println("</tr><tr><td width=\"50%\"><b><font color=\"#000080\">");
out.println("Enter The User ID</font></b></td><td width=\"50%\" colspan=\"2\">");
out.println("<input type=\"text\" name=\"CID\" size=\"20\"></td></tr>");
out.println("<tr><td width=\"50%\"><b><font color=\"#000080\">");
out.println("Enter The Password</font></b></td><td width=\"50%\" colspan=\"2\">");
out.println("<input type=\"pass\" name=\"CPWD\" size=\"20\"></td></tr>");
out.println("<tr><td width=\"50%\"> </td><td width=\"25%\" align=\"right\">");
out.println("<input type=\"submit\" value=\"Submit\" name=\"B1\"></td>");
out.println("<td width=\"25%\" align=\"right\">");
out.println("<input type=\"reset\" value=\"Reset\" name=\"B2\"></td></tr></table>");
out.println("</form></div>");
}
else
{
System.out.println("no loans");
out.println("<p align=\"center\"><font size=\"4\" color=\"#000080\"><b>No Loans Taken");
out.println("</b></font></p>");
}
out.println("<br><br><font color=red><MARQUEE><I>This option is for future enhancement (ATM Facility). The page is just displayed for knowing the facilities</I></MARQUEE></font>");
out.println("</body></html>");
}
catch(SQLException sqle4){
System.out.println("Sql4 Exception "+sqle4);
}
catch(ClassNotFoundException cnfe){
System.out.println("Class Not Found "+cnfe);
}
}
public void doGet(HttpServletRequest req,HttpServletResponse res) throws IOException,ServletException{
doPost(req,res);
}
}
NEXT ==>> class Mail ( ONLINE BANKING APPLICATION) SOURCE CODE