Results 1 to 4 of 4
  1. #1
    ananda is offline Member
    Join Date
    Jan 2012
    Posts
    1
    Rep Power
    0

    Default mini project for beginners

    [B][U]html main page

    <a href="html/creg.html">CREATE NEW PROFILE</a><br/>
    <a href="html/profile.html">ALREADY REGISTERED LOGIN HERE</a><br/>
    <a href="html/delete.html">DELETE MY PROFILE</a><br/>
    <a href="html/username.html">UPDATE MY PROFILE</a><br/>

    cr register

    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <SCRIPT TYPE="TEXT/JAVASCRIPT">
    function validate(CREG)
    {
    var a=document.getElementById("n").value;
    var b=document.getElementById("ad").value;

    //name
    if (a==null || a=="")
    {
    alert("First name must be filled out");
    document.getElementById("n").value = "";
    document.getElementById("n").focus();
    return false;
    }


    //address

    if (b==null || b=="")
    {
    alert("ADDRESS MUST BE FILLED");
    b="";
    document.getElementById("ad").focus();

    return false;
    }

    //gender
    if ( ( CREG.S[0].checked == false ) && ( CREG.S[1].checked == false ) )

    {

    alert ( "Please select your Gender " );

    return false;

    }



    //phone number
    var d=document.getElementById("no").value;

    if(isNaN(d)|| d.indexOf(" ")!=-1)
    {
    alert("Enter numeric value");
    return false;
    }
    if (d.length > 10 || d.length < 10){
    alert("Phone number should not be empty and contain 10 digits only");

    document.getElementById("no").value = "";
    document.getElementById("no").focus();
    return false;}

    //USERNAME
    var E=document.getElementById("UN").value;
    if (E==null ||E=="")
    {
    alert("User name must be filled out");
    document.getElementById("UN").value = "";
    document.getElementById("UN").focus();
    return false;
    }
    //password

    var f=document.getElementById("P").value;
    if (f==null || f=="")
    {
    alert("Enter a password");
    document.getElementById("P").value = "";
    document.getElementById("P").focus();
    return false;
    }



    //check box
    if ( CREG.CHNAME.checked == false )
    {
    alert ( "Please check the Terms & Conditions box." );
    return false;
    }



    }

    </script>





    </head>
    <body color="yellow">
    <fieldset>
    <legend align="center">CUSTOMER REGISTRATION</legend>
    <form name="CREG" method="get" action="../BankServlet" onsubmit="return validate(CREG)">
    <table align="center">
    <tr>
    <TD>FIRST NAME<FONT COLOR="RED">*</FONT>
    </td>
    <Td><INPUT TYPE="TEXT" name="FNAME" id="n">
    </Td>
    <TD>LAST NAME
    </TD>
    <TD><INPUT TYPE="TEXT" NAME="LNAME">
    </TR>
    <TR>
    <TD>ADDRESS<FONT COLOR="RED">*</FONT>
    </TD>
    <TD><INPUT TYPE="TEXT" NAME="ANAME" id="ad">
    </TD>
    </TR>
    <TR>
    <TD>GENDER<FONT COLOR="RED">*</FONT>
    </TD>
    <TD><INPUT TYPE="RADIO" NAME="S" id="s" VALUE="M">MALE<BR/>
    </TD>
    <TD><INPUT TYPE="RADIO" NAME="S" id="s" VALUE="F">FEMALE<BR/>
    </TD>

    <TR>
    <TD>PHONE NUMBER<FONT COLOR="RED">*</FONT>
    </TD>
    <TD><INPUT TYPE="TEXT" NAME="PNO" id="no" MAXLENGTH="10">
    </TD>
    </TR>

    <tr>
    <td>
    USERNAME<font color="red">*</font>
    </td>
    <td><input type="text" name="UNAME" id="UN">
    </td>
    </tr>
    <tr>
    <td>
    PASSWORD<font color="red">*</font>
    </td>
    <td><input type="PASSWORD" name="PWD" id="P">
    </td>
    </TR>





    <tr>
    <td><input type="Checkbox" name="CHNAME" value="gxg">
    </td>
    <td>I Agree for the terms and conditions
    </td>

    <TR>
    <TD ALIGN="CENTER">
    <INPUT TYPE="SUBMIT" VALUE="SUBMIT"/>
    </TD>
    <TD ALIGN="CENTER">
    <INPUT TYPE="RESET"/>
    </TD>
    </TR>
    </TABLE>
    </FORM>
    </fieldset>

    crsearch

    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
    <title>PROFILE DETAILS</title>
    </head>
    <body>


    <h1 align ="center"></h1>
    <form method="get" action="../ProfileServlet" >
    <h3 align="center">Enter the UserName<input type="text" value="" name="input"/> </h3>
    <h1 align="center"><input type="submit" value="VIEW MY PROFILE DETAILS"/></h1>

    </form>
    </body>
    </html>

    html delet

    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
    <title>Insert title here</title>
    </head>
    <body>
    <h1 align ="center"></h1>
    <form method="get" action="../DeleteServlet" >
    <h3 align="center">Enter the UserName<input type="text" value="" name="input1"/> </h3>
    <h1 align="center"><input type="submit" value="DELETE MY PROFILE DETAILS"/></h1>
    </form>
    </body>
    </html>

    JSP :

    view profile


    <%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
    <title>Bank List</title>
    </head>
    <body >

    <%@ page import = "com.tcs.bank.bean.*" %>
    <%@ page import ="com.tcs.bank.dao.ProfileDao"%>
    <%@ page import= "com.tcs.bank.controller.*"%>
    <%@page import ="java.sql.ResultSet" %>
    <%@ page import = "java.sql.*" %>
    <%@ page import="java.sql.*" %>
    <%@ page import="java.io.*" %>
    <%@ page import ="java.util.ArrayList" %>






    <h1 align = "center" > STUDENT DETAILS </h1>
    <%
    int count=0;
    HttpSession s=request.getSession();
    ResultSet rs=(ResultSet)session.getAttribute("haha");
    ResultSet rs1=(ResultSet)session.getAttribute("haha1");
    System.out.println("data retrieved");
    //ProfileDao pdd=new ProfileDao();
    //ResultSet rs=pdd.data();//
    System.out.println("done");
    System.out.println("done");
    while(rs1.next())
    {
    count++;
    }

    %>
    <%if(count!=0)
    {%>
    <TABLE border="1">
    <TR>

    <TD> First Name </TD>
    <TD> Last Name </TD>
    <TD> Address </TD>
    <td>Phone Number</td>
    <td>User Name</td>

    <td>Password</td>


    </TR>
    <%
    while (rs.next())
    {
    %>

    <TR>
    <TD>
    <%=rs.getString(1)%>
    </TD>
    <TD>
    <%=rs.getString(2)%>
    </TD>
    <TD>
    <%=rs.getString(3)%>
    </TD>
    <td><%=rs.getLong(4) %>
    </td>
    <td><%=rs.getString(5) %>
    </td>

    <td><%=rs.getString(6) %>
    </td>





    </TR>

    <%


    }
    %>



    </TABLE><%}
    else
    {
    out.println("<h2>No records found</h2>");
    }
    %>
    <%out.println(""); %>


    </body>
    </html>

    jsp succcess :

    <%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
    <title>Insert title here</title>
    </head>
    <body>
    <p>SUCCESS!!!!!!!</p>
    </body>
    </html>

    jsp delete :

    <%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
    <title>Insert title here</title>
    </head>
    <body>
    <h1>PROFILE DELETED!!!!!!!</h1>
    </body>
    </html>

    1st bean :

    package com.tcs.bank.bean;

    public class CusBean {

    private String fname;
    public String getFname() {
    return fname;
    }
    public void setFname(String fname) {
    this.fname = fname;
    }
    public String getLname() {
    return lname;
    }
    public void setLname(String lname) {
    this.lname = lname;
    }
    public String getAdd() {
    return add;
    }
    public void setAdd(String add) {
    this.add = add;
    }
    public String getUname() {
    return uname;
    }
    public void setUname(String uname) {
    this.uname = uname;
    }
    public String getPwd() {
    return pwd;
    }
    public void setPwd(String pwd) {
    this.pwd = pwd;
    }
    public long getPh() {
    return ph;
    }
    public void setPh(long ph) {
    this.ph = ph;
    }
    private String lname;
    private String add;
    private String uname;
    private String pwd;
    private long ph;


    }


    profile bean:

    package com.tcs.bank.bean;

    public class ProfileBean {

    String fname;
    public String getFname() {
    return fname;
    }
    public void setFname(String fname) {
    this.fname = fname;
    }
    public String getLname() {
    return lname;
    }
    public void setLname(String lname) {
    this.lname = lname;
    }
    public String getAname() {
    return aname;
    }
    public void setAname(String aname) {
    this.aname = aname;
    }
    public String getUname() {
    return uname;
    }
    public void setUname(String uname) {
    this.uname = uname;
    }
    public long getPno() {
    return pno;
    }
    public void setPno(long pno) {
    this.pno = pno;
    }
    public String getPwd() {
    return pwd;
    }
    public void setPwd(String pwd) {
    this.pwd = pwd;
    }
    String lname;
    String aname;
    String uname;
    long pno;
    String pwd;

    }

    DAO:
    Insert DAo :

    package com.tcs.bank.dao;

    import java.sql.Connection;
    import java.sql.ResultSet;
    import java.sql.Statement;

    import com.tcs.bank.dao.*;
    import com.tcs.bank.bean.CusBean;

    public class InsertDao {

    public int Insert(CusBean cb) throws Exception
    {
    Statement statement = null;
    Connection con = null;
    int i=0;
    try {
    con = connectiondao.getConnection();
    // Create a statement object
    statement = con.createStatement();


    // Execute the SQL query
    i=statement.executeUpdate("INSERT INTO customer values('"+cb.getFname()+"','"+cb.getLname()+"','"+ cb.getAdd()+"',"+cb.getPh()+" ,'"+cb.getUname()+"','"+cb.getPwd()+"')");
    System.out.println("details added in DB");
    con.commit();
    // Print the result set
    }
    catch (Exception e) {
    e.printStackTrace();
    } finally {
    statement.close();
    con.close();
    }
    return i;
    }




    }


    profile dao :

    package com.tcs.bank.dao;

    import java.sql.Connection;
    import java.sql.ResultSet;
    import java.sql.Statement;
    import com.tcs.bank.controller.*;
    import com.tcs.bank.dao.connectiondao;





    public class ProfileDao {

    public ResultSet data(String ee) throws Exception{
    ResultSet rs=null;
    Statement statement = null;
    Connection con = null;


    con = connectiondao.getConnection();
    statement = con.createStatement();


    rs=statement.executeQuery("select * from customer where username='"+ee+"'");
    System.out.println("Details received form DB");


    return rs;
    }
    }


    Delete dao :

    package com.tcs.bank.dao;

    import java.sql.Connection;
    import java.sql.ResultSet;
    import java.sql.Statement;

    import com.tcs.bank.controller.*;
    public class DeleteDao {

    public ResultSet data1(String ee1) throws Exception{


    ResultSet rs=null;
    Statement statement = null;
    Connection con = null;


    con = connectiondao.getConnection();
    statement = con.createStatement();



    rs=statement.executeQuery("delete from customer where username='"+ee1+"'");
    con.commit();
    System.out.println("Details received form DB");
    con.commit();
    return rs;


    }

    }

    Controller :

    1st bank servlet :

    package com.tcs.bank.controller;

    import java.io.IOException;
    import javax.servlet.ServletException;
    import javax.servlet.http.HttpServlet;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    import com.tcs.bank.bean.*;
    import com.tcs.bank.dao.*;

    public class BankServlet extends HttpServlet {
    private static final long serialVersionUID = 1L;

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    // TODO Auto-generated method stub
    int d=0;

    try{
    CusBean cb=new CusBean();
    String fn=request.getParameter("FNAME");
    String ln=request.getParameter("LNAME");
    String ad=request.getParameter("ANAME");
    String un=request.getParameter("UNAME");
    String pd=request.getParameter("PWD");
    long ph=Long.parseLong(request.getParameter("PNO"));

    cb.setFname(fn);
    cb.setLname(ln);
    cb.setAdd(ad);
    cb.setUname(un);
    cb.setPwd(pd);
    cb.setPh(ph);

    InsertDao id=new InsertDao();
    d=id.Insert(cb);

    if(d==1)
    response.sendRedirect("jsp/success.jsp");
    else
    response.sendRedirect("jsp/error.jsp");
    }
    catch(Exception e)
    {
    e.printStackTrace();
    }
    }

    }

    profile servlet :

    package com.tcs.bank.controller;

    import java.io.IOException;
    import java.sql.ResultSet;

    import javax.servlet.ServletException;
    import javax.servlet.http.HttpServlet;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    import javax.servlet.http.HttpSession;

    import com.tcs.bank.dao.ProfileDao;

    public class ProfileServlet extends HttpServlet {
    private static final long serialVersionUID = 1L;


    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

    HttpSession session=request.getSession();
    ResultSet rs=null;
    ProfileDao dd = new ProfileDao();
    ResultSet rs1=null;
    ProfileDao dd1 = new ProfileDao();

    String ee=request.getParameter("input");
    try {
    //ResultSet rs1 = dd.data();



    rs=dd.data(ee);
    rs1=dd1.data(ee);

    session.setAttribute("haha", rs);
    session.setAttribute("haha1", rs1);
    System.out.println("rd");
    response.sendRedirect("jsp/myprofile.jsp");
    System.out.print("rs");
    }
    catch(Exception e) {
    e.printStackTrace();

    }


    }



    }

    delete servlet:

    package com.tcs.bank.controller;

    import java.io.IOException;
    import java.sql.ResultSet;

    import javax.servlet.ServletException;
    import javax.servlet.http.HttpServlet;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    import javax.servlet.http.HttpSession;

    import com.tcs.bank.dao.DeleteDao;
    import com.tcs.bank.dao.ProfileDao;
    import com.tcs.bank.dao.*;
    /**
    * Servlet implementation class DeleteServlet
    */
    public class DeleteServlet extends HttpServlet {
    private static final long serialVersionUID = 1L;

    /**
    * @see HttpServlet#HttpServlet()
    */
    public DeleteServlet() {
    super();
    // TODO Auto-generated constructor stub
    }

    /**
    * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
    */
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    // TODO Auto-generated method stub


    HttpSession session=request.getSession();
    ResultSet rs=null;
    DeleteDao dd = new DeleteDao();


    String ee1=request.getParameter("input1");
    try {




    rs=dd.data1(ee1);


    session.setAttribute("haha", rs);

    System.out.println("rd");
    response.sendRedirect("jsp/deleteprofile.jsp");
    System.out.print("rs");
    }
    catch(Exception e) {
    e.printStackTrace();


    }

    }

    /**
    * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
    */
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    // TODO Auto-generated method stub
    }

    }

    Connection dao:

    package com.tcs.bank.dao;
    import java.sql.Connection;
    import java.sql.DriverManager;

    public class connectiondao {

    public static Connection getConnection() {
    String serverName = "172.24.137.30";
    String portNumber = "1521";
    String sid = "ora10G";
    String url = "jdbc:oracle:thin:@" + serverName + ":" + portNumber + ":" + sid;
    String username = "e537149";
    String password = "fLclKoblb";
    Connection conn = null;

    try
    {
    // load the JDBC-ODBC Bridge driver
    Class.forName("oracle.jdbc.driver.OracleDriver");

    // connect to db using DriverManager
    System.out.println("The Jdbc URL is "+url);
    conn =DriverManager.getConnection( url, username, password );
    } catch (Exception e) {
    e.printStackTrace();
    }
    return conn;
    }
    }

    END

  2. #2
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    14,051
    Blog Entries
    7
    Rep Power
    23

    Default Re: mini project for beginners

    And your question is?

    kind regards,

    Jos
    The only person who got everything done by Friday was Robinson Crusoe.

  3. #3
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,315
    Blog Entries
    1
    Rep Power
    27

  4. #4
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    14,051
    Blog Entries
    7
    Rep Power
    23

    Default Re: mini project for beginners

    Sounds reasonable; I'll close this one, we already have more than enough wallpaper.

    kind regards,

    Jos
    The only person who got everything done by Friday was Robinson Crusoe.

Similar Threads

  1. Java project for beginners/experienced
    By Si1ver in forum Jobs Offered
    Replies: 0
    Last Post: 04-12-2011, 11:09 PM
  2. anyone who can help me fix this opera mini 5.1.22296
    By ejstrider in forum Sun Java Wireless Toolkit
    Replies: 0
    Last Post: 02-05-2011, 06:23 AM
  3. Java Mini-Game!
    By Ehkx in forum New To Java
    Replies: 3
    Last Post: 01-11-2011, 11:38 PM
  4. How to do parsing and mini-Compler for ISA?
    By Nael in forum New To Java
    Replies: 1
    Last Post: 02-11-2009, 01:01 AM
  5. The 3 Word Story [Mini Game]
    By Eku in forum Forum Lobby
    Replies: 90
    Last Post: 11-16-2008, 10:01 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •