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 UPDetails extends HttpServlet{
Connection con;
Statement st;
ResultSet rs;
public void doPost(HttpServletRequest req,HttpServletResponse res) throws IOException,ServletException{
try{
Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
con=DriverManager.getConnection("jdbc:odbc:bank");
st=con.createStatement();
int rano=Integer.parseInt(req.getParameter("ANO"));
String str="SELECT * FROM USERTAB WHERE ACCOUNTNO="+rano;
rs=st.executeQuery(str);
rs.next();
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);
String lname=rs.getString(2);
String fname=rs.getString(3);
String eid=rs.getString(4);
String hname=rs.getString(5);
String sname=rs.getString(6);
String city=rs.getString(7);
String cname=rs.getString(8);
String tno=rs.getString(9);
String occ=rs.getString(10);
String income=rs.getString(11);
out.println("<html><head>");
out.println("<script language=\"javascript\">function val1()");
out.println("{if(form1.t1.value==\"\"){alert(\"RE-ENTER LAST NAME\");return false;}");
out.println("if(form1.t2.value==\"\"){alert(\"RE-ENTER FIRST NAME\");return false;}");
out.println("if(form1.t3.value==\"\"){alert(\"RE-ENTER E-MAIL ID\");return false;}");
out.println("if((form1.t3.value.indexOf('@',0)==-1)||(form1.t3.value.indexOf('.',0)==-1)||(form1.t3.value.length<7))");
out.println("{alert(\"INVALID E-MAIL ADDRESS\");return false;} ");
out.println("if(form1.t4.value==\"\"){ alert(\"RE-ENTER HOUSE NAME\");return false;}");
out.println("if(form1.t5.value==\"\"){alert(\"RE-ENTER STREET NAME\");return false;}");
out.println("if(form1.t6.value==\"\"){alert(\"RE-ENTER CITY\");return false;}");
out.println("if(form1.t7.value==\"\"){alert(\"RE-ENTER TELEPHONE NUMBER\");return false;}");
out.println("if(form1.t8.value==\"\"){alert(\"RE-ENTER OCCUPATION\");return false;}");
out.println("if(form1.t9.value==\"\"){alert(\"RE-ENTER ANNUAL INCOME\");return false;}");
out.println("}</script>");
out.println("<title>OnLineEntry</title></head>");
out.println("<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="+rano+"\">Welcome");
out.println("</a></td><td width=\"18%\" valign=\"top\" align=\"center\">");
out.println("<a href=\"http:\\\\localhost:8080\\examples\\servlet\\ADetail?ANO="+rano+"\">Account Details");
out.println("</a></td><td width=\"14%\" valign=\"top\" align=\"center\">");
out.println("<a href=\"http:\\\\localhost:8080\\examples\\servlet\\WithDraw?ANO="+rano+"\">Withdrawals");
out.println("</a></td><td width=\"12%\" valign=\"top\" align=\"center\">");
out.println("<a href=\"http:\\\\localhost:8080\\examples\\servlet\\Deposit?ANO="+rano+"\">Deposits");
out.println("</a></td><td width=\"12%\" valign=\"top\" align=\"center\">");
out.println("<a href=\"http:\\\\localhost:8080\\examples\\servlet\\Loan?ANO="+rano+"\">Loans");
out.println("</a></td><td width=\"12%\" valign=\"top\" align=\"center\">");
out.println("<a href=\"http:\\\\localhost:8080\\examples\\servlet\\Mail?ANO="+rano+"\">Mail Us");
out.println("</a></td><td width=\"10%\" valign=\"top\" align=\"center\">");
out.println("<a href=\"http:\\\\localhost:8080\\examples\\servlet\\Option?ANO="+rano+"\">Options");
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=\"4\">");
out.println(rano);
out.println("</font></b></font></td></tr></table>");
out.println("<p align=\"center\"> <img border=\"0\" src=\"http:\\\\localhost:8080\\examples\\servlets\\images\\update.jpg\" width=\"403\" height=\"83\"></p>");
out.println("<p><b>Update your Personal Details</b></p>");
out.println("<table align=center width=75% border=1 height=\"405\">");
out.println("<form name=\"form1\" onsubmit=\"return val1()\" action=\"http:\\\\localhost:8080\\examples\\servlet\\ProcessDetails\" method=post>");
out.println("<input type=hidden name=ANO value="+rano+">");
out.println("<tr><td height=\"25\">Last name : <td height=\"25\">");
out.println("<input type=text name=t1 size=20 maxlength=20 value="+lname+">");
out.println("</tr><tr><td height=\"25\">First name : <td height=\"25\">");
out.println("<input type=text name=t2 size=20 maxlength=20 value="+fname+">");
out.println("</tr><tr><td height=\"25\">E-mail ID : <td height=\"25\">");
out.println("<input type=text name=t3 size=20 maxlength=30 value="+eid+">");
out.println("</tr><tr><td height=\"25\">House name : <td height=\"25\">");
out.println("<input type=text name=t4 size=20 maxlength=30 value="+hname+">");
out.println("</tr><tr><td height=\"25\">Street : <td height=\"25\">");
out.println("<input type=text name=t5 size=20 maxlength=30 value="+sname+">");
out.println("</tr><tr><td height=\"25\">City : <td height=\"25\">");
out.println("<input type=text name=t6 size=20 maxlength=30 value="+city+">");
out.println("</tr><tr><td height=\"25\">Country : <td height=\"25\">");
out.println("<select name=s1 size=1>");
if (cname.equals("INDIA"))
out.println("<option value=\"INDIA\" SELECTED>INDIA");
else
out.println("<option value=\"INDIA\">INDIA");
if (cname.equals("BANGLADESH"))
out.println("<option value=\"BANGLADESH\" SELECTED>BANGLADESH");
else
out.println("<option value=\"BANGLADESH\">BANGLADESH");
if (cname.equals("BHUTAN"))
out.println("<option value=\"BHUTAN\" SELECTED>BHUTAN");
else
out.println("<option value=\"BHUTAN\">BHUTAN");
if (cname.equals("PAKISTAN"))
out.println("<option value=\"PAKISTAN\" SELECTED>PAKISTAN");
else
out.println("<option value=\"PAKISTAN\">PAKISTAN");
if (cname.equals("MYANMAR"))
out.println("<option value=\"MYANMMAR\" SELECTED>MYANMAR");
else
out.println("<option value=\"MYANMMAR\">MYANMAR");
if (cname.equals("NEPAL"))
out.println("<option value=\"NEPAL\" SELECTED>NEPAL");
else
out.println("<option value=\"NEPAL\">NEPAL");
if (cname.equals("SRILANKA"))
out.println("<option value=\"SRILANKA\" SELECTED>SRILANKA");
else
out.println("<option value=\"SRILANKA\">SRILANKA");
if (cname.equals("OTHER"))
out.println("<option value=\"OTHER\" SELECTED>OTHER ");
else
out.println("<option value=\"OTHER\">OTHER ");
out.println("</select>");
out.println("</tr><tr><td height=\"25\">Telephone no : <td height=\"25\">");
out.println("<input type=text name=t7 size=20 maxlength=20 value="+tno+">");
out.println("</tr><tr><td height=\"25\">Occupation : <td height=\"25\">");
out.println("<input type=text name=t8 size=20 maxlength=30 value="+occ+">");
out.println("</tr><tr><td height=\"26\">Annual Income : <td height=\"26\">");
out.println("<input type=text name=t9 size=20 maxlength=20 value="+income+">");
out.println("</tr><tr><td height=\"27\"><input type=submit value=\"Update\" >");
out.println("<td height=\"27\"><input type=reset value=\"Reset\"></tr></table>");
out.println("</form></body></html>");
}
catch(SQLException sqle4){
System.out.println("Sql4 Exception "+sqle4);
}
catch(ClassNotFoundException cnfe){
System.out.println("Class Not Found "+cnfe);
}
}//END OF doPost
public void doGet(HttpServletRequest req,HttpServletResponse res) throws IOException,ServletException{
doPost(req,res);
}
}
NEXT ==>> class Welcome -ONLINE BANKING PROJECT