Results 1 to 5 of 5
  1. #1
    anupama is offline Member
    Join Date
    Dec 2010
    Posts
    3
    Rep Power
    0

    Default Getting problem inserting data in data base

    I have 2 jsps and am submitting data in Data base. My Tomcat is able to recognize 1st(Employee_Masterpage.jsp) JSP but not second(Employee_Masterpage_response.jsp). I am getting error like "HTTP Status 404 - /Employee_Masterpage_response.jsp
    "

    Employee_Masterpage.jsp

    <%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
    <%@ page import="java.sql.*" %>
    <%@ page import="java.io.*" %>

    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <html>
    <script type="text/javascript" src="js/jsptabcontrol.js" ></script>
    <link href="/css/my-jsptabcontrol.css" rel="stylesheet" type="text/css"/>

    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
    <title>Insert title here</title>
    </head>
    <body>
    Employee Info
    <form name="Emp_res" action="Employee_Masterpage_response.jsp" method="post">
    <TABLE>
    <tr><td>SSN</td> <td><input type = "text" name = "ssn" value=""></td></tr><br></br>
    <tr>
    <td>
    Name
    </td>
    <td>
    First Name
    <input name="fname" value="" type="text"></td>
    <td>Last Name
    <input name="lname" value="" type="text"></td></tr><br></br>
    <tr><td>Age</td> <td><input type = "text" name = "age"></td></tr><br></br>
    <tr><td>Sex</td> <td><select name="selectsex">
    <option value=""></option>
    <option value="Male">M</option>
    <option value="FeMale">F</option>
    </select>
    </td></tr><br></br>
    <tr><td>Martial Status</td> <td><select name="mar_sta">
    <option value=""></option>
    <option value="Married">M</option>
    <option value="Unmarried">UM</option>
    </select>
    </td></tr><br></br>
    <tr>
    <td>
    Phone No
    </td>
    <td>
    Mobile No
    <input name="M_phno" value="" type="text"></td>
    <td>Landline No
    <input name="L_phno" value="" type="text"></td></tr><br></br>
    <tr><td>Enter the DOB :</td> <td><input type = "text" name = "dob" value=""></td></tr><br></br>
    <tr><td>Enter the DOJ :</td> <td><input type = "text" name = "doj" value=""></td></tr><br></br>
    <tr>
    <td>
    Address
    </td>
    <td>
    Present Address
    <input name="pre_Add" value="" type="text"></td>
    <td>Permanent Address
    <input name="par_add" value="" type="text"></td></tr><br></br>
    <tr><td>Email</td> <td><input type = "text" name = "email" value=""></td></tr><br></br>
    <tr><td>Training Program</td> <td><input type = "text" name = "trng_prg" value=""></td></tr><br></br>
    <tr><td>Driving License no</td> <td><input type = "text" value="" name = "lic_no"></td></tr><br></br>
    <tr><td>PAN No</td> <td><input type = "text" value="" name = "pan_no"></td></tr><br></br>
    <tr><td>Achievements</td> <td><input type = "text" value="" name = "sig_ach"></td></tr><br></br>
    <tr><td><input type="submit" name = "Submit" value="Submit"></td></tr><br></br>

    </TABLE>

    </form>


    </body>
    </html>

    Employee_Masterpage_response.jsp


    <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
    <%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
    <%@ page import="java.sql.*" %>
    <%@ page import="java.io.*" %>


    <html>
    <script type="text/javascript" src="js/jsptabcontrol.js" ></script>
    <link href="/css/my-jsptabcontrol.css" rel="stylesheet" type="text/css"/>

    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
    <title>Insert title here</title>
    </head>

    <%
    out.print(request.getParameter("ssn"));
    String StrEmployee_ssn=request.getParameter("ssn");
    String StrFirst_Name=request.getParameter("fname");
    String StrLast_Name=request.getParameter("lname");
    String StrAge=request.getParameter("age");
    String StrSex=request.getParameter("selectsex");
    String StrLandline_No=request.getParameter("L_phno");
    String StrMobile_No=request.getParameter("M_phno");
    String StrMarital_Status=request.getParameter("mar_sta");
    String StrDOB=request.getParameter("dob");
    String StrDOJ=request.getParameter("doj");
    String StrPres_Add=request.getParameter("pre_add");
    String StrPerm_Add=request.getParameter("par_add");
    String StrTraining_Program=request.getParameter("trng_prg ");
    String StrEmail=request.getParameter("email");
    String StrDriv_Lic_No=request.getParameter("lic_no");
    String StrPAN_No=request.getParameter("pan_no");
    String StrSignificant_Achievement=request.getParameter("s ig_ach");

    Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
    Connection connection = DriverManager.getConnection("jdbc:oracle:thin:@cha ngeme1:1521:XE", "sys as sysdba", "cognos");

    Statement statement = connection.createStatement();
    String sql = ("INSERT INTO Employee_Detail VALUES ('" + StrEmployee_ssn + "','" + StrFirst_Name + "','" + StrLast_Name + "','"+ StrAge +"','"+ StrSex +"','"+ StrLandline_No +"','"+ StrMobile_No +"','"+ StrMarital_Status +"','"+ StrDOB +"','"+ StrDOJ +"','"+ StrPres_Add +"','"+ StrPerm_Add +"','"+ StrTraining_Program +"','"+ StrEmail +"','"+ StrDriv_Lic_No +"','"+ StrPAN_No +"','"+ StrSignificant_Achievement +"') ");
    statement.executeUpdate(sql);

    connection.close();


    %>
    <body>
    <h1>Employee Info</h1>
    <tr>ssn
    <%=StrEmployee_ssn%>
    </tr>
    <tr>
    <td>
    Name
    </td>
    <td>
    First Name
    <%=StrFirst_Name%>
    </td>
    <td>Last Name
    <%=StrLast_Name%></td></tr><br></br>
    <tr><td>Age</td> <td><%=StrAge%></td></tr><br></br>
    <tr><td>Sex</td> <td><%=StrSex%></td>
    </td><tr><br></br>
    <tr><td>Marital Status</td> <td><%=StrMarital_Status%></td></tr>
    <tr>
    <td>
    Phone No
    </td>
    <td>
    Mobile No
    </td><td><%=StrMobile_No%></td>
    <td>Landline No
    </td><td><%=StrLandline_No%></td></tr><br></br>
    <tr><td>Enter the DOB :</td> <td><%=StrDOB%></td><tr><br></br>
    <tr><td>Enter the DOJ :</td> <td><%=StrDOJ%></td><tr><br></br>
    <tr>
    <td>
    Address
    </td>
    <td>
    Present Address
    </td><td><%=StrPres_Add%></td>
    <td>Permanent Address
    </td><td><%=StrPerm_Add%></td></tr><br></br>
    <tr><td>Email</td> <td><%=StrEmail%></td><tr><br></br>
    <tr><td>Driving License no</td> <td><%=StrDriv_Lic_No%></td><tr><br></br>
    <tr><td>PAN No</td><td><%=StrPAN_No%></td><tr><br></br>
    <tr><td>Achievements</td><td><%=StrSignificant_Achievement%></td><tr><br></br>

    </body>
    </html>

    web.xml

    <?xml version="1.0" encoding="UTF-8"?>
    <web-app id="WebApp_ID" version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
    <display-name>Treasury_employee</display-name>
    <welcome-file-list>

    <welcome-file>Employee_Masterpage.jsp</welcome-file>

    </welcome-file-list>
    <display-name>InsertData</display-name>
    <description>no description</description>
    <servlet>
    <servlet-name>Employee_Masterpage</servlet-name>
    <jsp-file>/Employee_Masterpage.jsp</jsp-file>
    </servlet>
    <servlet>
    <servlet-name>Employee_Masterpage_response</servlet-name>
    <jsp-file>/Employee_Masterpage_response.jsp</jsp-file>
    </servlet>
    <session-config>
    <session-timeout>30</session-timeout>
    </session-config>

    </web-app>

    i am using Tomcat 5.5 and Oracle 10g
    Please suggest me how to solve this issue
    Last edited by anupama; 12-15-2010 at 10:04 PM.

  2. #2
    anupama is offline Member
    Join Date
    Dec 2010
    Posts
    3
    Rep Power
    0

    Default

    Sorry, i have mistaken here. my 1st page is working. i am using Tomcat 5.5 and Oracle 10g

  3. #3
    makpandian's Avatar
    makpandian is offline Senior Member
    Join Date
    Dec 2008
    Location
    Chennai
    Posts
    439
    Rep Power
    6

    Default

    What was the mistake? Everything is fine in your code.
    Mak
    (Living @ Virtual World)

  4. #4
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    11,798
    Rep Power
    19

    Default

    Well, if by "fine" you ignore that it's doing all that db INSERT stuff ina JSP and not a Servlet, as well as concatenating the INSERT statement rather than using a PreparedStatement and not closing the connection resources properly...then yes, I suppose so.
    ;)

  5. #5
    anupama is offline Member
    Join Date
    Dec 2010
    Posts
    3
    Rep Power
    0

    Default

    The problem is when i click on submit button on Employee_Masterpage.jsp then i get "HTTP Status 404 - /Employee_Masterpage_response.jsp" error

Similar Threads

  1. Replies: 5
    Last Post: 04-05-2010, 01:24 PM
  2. data structure and data base??
    By ahmed13 in forum Advanced Java
    Replies: 8
    Last Post: 03-27-2009, 05:48 AM
  3. how to store the data in data base
    By eclipse3.4ide in forum New To Java
    Replies: 5
    Last Post: 02-03-2009, 04:25 AM
  4. error while retrieving data from data base
    By kirtesh4u in forum New To Java
    Replies: 5
    Last Post: 11-15-2008, 04:10 PM
  5. Replies: 0
    Last Post: 12-24-2007, 09:47 AM

Tags for this Thread

Posting Permissions

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