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=<%=customerdetails.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=<%=customerdetails.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(homephone));
customerdetails.setHandphone(Integer.parseInt(handphone));
customerdetails.setOfficephone(Integer.parseInt(officephone));
// 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
This post has been edited by Atli: 30 July 2012 - 05:53 AM
Reason for edit:: Added [code] tags, and fixed the format of the post. Please use the "Preview Post" button to make sure your post is understandable before posting!

New Topic/Question
Reply


MultiQuote








|