Results 1 to 6 of 6
  1. #1
    sara91 is offline Member
    Join Date
    Jul 2012
    Posts
    2
    Rep Power
    0

    Default *Very Urgent* Need help with Update customer profile jsp page

    I am new to java and i need urgent help with updating customer information where the text boxes will retrieve data from the database and once user edits the information, user would need to click on update and then the information should update in the database and show the new information in the text boxes as well. But when ever i run there is always this error :

    org.apache.jasper.JasperException: An exception occurred processing JSP page /editcheckout.jsp at line 19

    16: UpdateCustomerDetails customerdetails = (UpdateCustomerDetails) request.getAttribute("customerdetails");
    17: %>
    18:
    19: <form action="UpdateCustomerServlet?Cust_ID=<%=customerd etails.getCustid()%>" method="get">
    20: <table>
    21: <tr>
    22: <td>Product ID</td>







    This is the jsp page: editcheckout.jsp

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


    <!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>Product View</title>
    </head>
    <body>
    <h1>Product Edit Page</h1>

    <%
    UpdateCustomerDetails customerdetails = (UpdateCustomerDetails) request.getAttribute("customerdetails");
    %>

    <form action="UpdateCustomerServlet?Cust_ID=<%=customerd etails.getCustid()%>" method="get">
    <table>
    <tr>
    <td>Product ID</td>
    <td><input readonly="readonly" name="custid" value="<%=customerdetails.getCustid()%>" disabled="disabled"></td>
    </tr>
    <tr>
    <td>Product Name</td>
    <td><input name="name" value="<%=customerdetails.getName()%>"></td>
    </tr>
    <tr>
    <td>Product Description</td>
    <td><input name="address" value="<%=customerdetails.getAddress()%>"></td>
    </tr>
    <tr>
    <td>Product Quantity</td>
    <td><input name="email" value="<%=customerdetails.getEmail()%>"></td>
    </tr>
    <tr>
    <td>Product Quantity</td>
    <td><input name="homephone" value="<%=customerdetails.getHomephone()%>"></td>
    </tr>
    <tr>
    <td>Product Quantity</td>
    <td><input name="handpone" value="<%=customerdetails.getHandphone()%>"></td>
    </tr>
    <tr>
    <td>Product Quantity</td>
    <td><input name="officephone" value="<%=customerdetails.getOfficephone()%>"></td>
    </tr>
    <tr>
    <td></td>
    <td><input type="submit" name="delete" value="Delete"> <input type="submit" name="update" value="Update"></td>
    </tr>
    </table>
    </form>
    <br><br><a href="checkout2.jsp">Back</a> to Product Search Page.
    </body>
    </html>
    This is the update product method

    public int updateCustomer(UpdateCustomerDetails customerdetails) throws Exception {
    int return_code = 0;

    try {
    PreparedStatement ps;
    ps = conn
    .prepareStatement("UPDATE C.Cust_Name, C.Cust_HandPhone, C.Cust_OfficePhone, C.Cust_HomePhone, C.Cust_Email, A.Cust_Addresss, A.Cust_ID " +
    "from grocery.address A INNER JOIN grocery.customer C ON A.Cust_ID = C.Cust_ID SET Cust_Name=?, Cust_HandPhone=?, Cust_OfficePhone=?, Cust_HomePhone=?, Cust_Email=?, Cust_Addresss=? WHERE Cust_ID=?");

    ps.setInt(1, customerdetails.getCustid());
    ps.setString(2, customerdetails.getName());
    ps.setString(3, customerdetails.getAddress());
    ps.setString(4, customerdetails.getEmail());
    ps.setInt(5, customerdetails.getHomephone());
    ps.setInt(6, customerdetails.getHandphone());
    ps.setInt(7, customerdetails.getOfficephone());
    return_code = ps.executeUpdate();

    conn.close();
    } catch (Exception ex) {
    throw new Exception("Error: " + ex.getMessage());
    }

    return return_code;
    }

    This is the servlet page: UpdateCustomerServlet.java

    package gsservlet;

    import gsdatabase.GSDBAO;

    import gsmodel.UpdateCustomerDetails;

    import java.io.IOException;
    import java.io.PrintWriter;
    import javax.servlet.ServletException;
    import javax.servlet.annotation.WebServlet;
    import javax.servlet.http.HttpServlet;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    /**
    * Servlet implementation class UpdateCustomerServlet
    */
    @WebServlet("/UpdateCustomerServlet")

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

    /**
    * @see HttpServlet#HttpServlet()
    */
    public UpdateCustomerServlet() {
    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
    int return_code;

    try {
    // Get the PrintWriter object
    PrintWriter writer = response.getWriter();
    writer.write("<html><body>");

    // Get product information from request.getParameter()
    String custid = request.getParameter("custid");
    String name = request.getParameter("name");
    String address = request.getParameter("address");
    String email = request.getParameter("email");
    String homephone = request.getParameter("homephone");
    String handphone = request.getParameter("handphone");
    String officephone = request.getParameter("officephone");

    // If "UPDATE" button is clicked
    if (request.getParameter("update") != null) {
    // Create an instance of ProductBean object
    UpdateCustomerDetails customerdetails = new UpdateCustomerDetails();
    // Set the attribute values for the newly created object
    customerdetails.setCustid(Integer.parseInt(custid) );
    customerdetails.setName(name);
    customerdetails.setAddress(address);
    customerdetails.setEmail(email);
    customerdetails.setHomephone(Integer.parseInt(home phone));
    customerdetails.setHandphone(Integer.parseInt(hand phone));
    customerdetails.setOfficephone(Integer.parseInt(of ficephone));

    // Invoke the ProductBeanDAO's updateProduct() method
    GSDBAO myGSDBAO = new GSDBAO();
    return_code = myGSDBAO.updateCustomer(customerdetails);

    if (return_code != 0)
    writer.write("UPDATE successful!<br><br>");
    else
    writer.write("UPDATE failed!<br><br>");
    writer.write("<a href=\"checkout.jsp\">Back</a> to Product Search Page.");

    }
    // If "DELETE" button is clicked
    //else if (request.getParameter("delete") != null) {
    // Invoke the ProductBeanDAO's deleteProduct() method
    // GSDBAO myGSDBAO = new GSDBAO();
    // return_code = myGSDBAO.deleteProductByID(Integer
    // .parseInt(prod_id));

    // if (return_code != 0)
    // writer.write("DELETE successful!<br><br>");
    // else
    // writer.write("DELETE failed!<br><br>");
    //writer.write("<a href=\"ProductSearch.html\">Back</a> to Product Search Page.");

    //}

    writer.write("</body></html>");
    } catch (Exception ex) {
    System.out.println("Error: " + ex.getMessage());
    }
    }


    /**
    * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
    */

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

    }
    }

    This is UpdateCustomeDetails.java


    package gsmodel;

    import java.io.Serializable;

    public class UpdateCustomerDetails implements Serializable{

    private int custid;
    private String name;
    private String address;
    private String email;
    private int homephone;
    private int handphone;
    private int officephone;
    public int getCustid() {
    return custid;
    }
    public void setCustid(int custid) {
    this.custid = custid;
    }
    public String getName() {
    return name;
    }
    public void setName(String name) {
    this.name = name;
    }
    public String getAddress() {
    return address;
    }
    public void setAddress(String address) {
    this.address = address;
    }
    public String getEmail() {
    return email;
    }
    public void setEmail(String email) {
    this.email = email;
    }
    public int getHomephone() {
    return homephone;
    }
    public void setHomephone(int homephone) {
    this.homephone = homephone;
    }
    public int getHandphone() {
    return handphone;
    }
    public void setHandphone(int handphone) {
    this.handphone = handphone;
    }
    public int getOfficephone() {
    return officephone;
    }
    public void setOfficephone(int officephone) {
    this.officephone = officephone;
    }

    }
    I really hope anyone could help me with this problem asap, because this is very urgent

  2. #2
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,089
    Rep Power
    20

    Default Re: *Very Urgent* Need help with Update customer profile jsp page

    Please use
    Java Code:
     tags
    when posting code as that lot is hard to read without them.
    Are there really line breaks in those scriptlets?
    Also in that exception message...is there really a space in 'customerd etails.getCustid'?
    Please do not ask for code as refusal often offends.

    ** This space for rent **

  3. #3
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,409
    Rep Power
    20

    Default Re: *Very Urgent* Need help with Update customer profile jsp page

    Recommended reading -- also the rest of that page.

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  4. #4
    DarrylBurke's Avatar
    DarrylBurke is offline Forum Police
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,409
    Rep Power
    20

    Default Re: *Very Urgent* Need help with Update customer profile jsp page

    Moved from New to Java

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  5. #5
    shahid nx is offline Member
    Join Date
    Aug 2012
    Posts
    2
    Rep Power
    0

    Default Re: *Very Urgent* Need help with Update customer profile jsp page

    please tell me how to create new post in this forum i m not seeing that option

  6. #6
    Tolls is offline Moderator
    Join Date
    Apr 2009
    Posts
    12,089
    Rep Power
    20

    Default Re: *Very Urgent* Need help with Update customer profile jsp page

    At the top of each sub forum there is a Post New Thread button.
    Please do not ask for code as refusal often offends.

    ** This space for rent **

Similar Threads

  1. Help with add Customer application
    By Ciggy in forum New To Java
    Replies: 5
    Last Post: 04-11-2012, 04:34 AM
  2. automatic update page
    By angleit in forum JavaServer Pages (JSP) and JSTL
    Replies: 0
    Last Post: 07-05-2011, 12:45 PM
  3. a Queue of customer in the GUI
    By jonywalker123 in forum Advanced Java
    Replies: 2
    Last Post: 02-26-2009, 11:02 PM
  4. Replies: 1
    Last Post: 02-11-2009, 06:54 AM
  5. unable to update MYSQL with values from jsp page
    By koushika in forum JavaServer Pages (JSP) and JSTL
    Replies: 0
    Last Post: 03-27-2008, 01:35 AM

Posting Permissions

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