3 Replies - 11760 Views - Last Post: 30 July 2012 - 05:13 PM

#1 sara91   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 30-July 12

Error while trying to open update customer page

Posted 30 July 2012 - 04:20 AM

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: %>
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"
<%@ page import="java.util.*,gsmodel.*"%>

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

		UpdateCustomerDetails customerdetails = (UpdateCustomerDetails) request.getAttribute("customerdetails");

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

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();

							} 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

public class UpdateCustomerServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
     * @see HttpServlet#HttpServlet()
    public UpdateCustomerServlet() {
        // 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();

			// 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

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

				if (return_code != 0)
					writer.write("UPDATE successful!<br><br>");
					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.");


		} 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!

Is This A Good Question/Topic? 0
  • +

Replies To: Error while trying to open update customer page

#2 macosxnerd101   User is offline

  • Games, Graphs, and Auctions
  • member icon

Reputation: 12316
  • View blog
  • Posts: 45,416
  • Joined: 27-December 08

Re: Error while trying to open update customer page

Posted 30 July 2012 - 08:53 AM

Moved to Java EE.
Was This Post Helpful? 0
  • +
  • -

#3 RCR   User is offline

  • New D.I.C Head
  • member icon

Reputation: 7
  • View blog
  • Posts: 33
  • Joined: 04-July 12

Re: Error while trying to open update customer page

Posted 30 July 2012 - 03:38 PM

Welcome to the Java world! Since you are fairly new, let me introduce you to the structure of a Java program, this may be a part of your problem

Java programs are made like this:

package goeshere;
import yourImports.*;
public class StructureOfAProgram extends program implements interface {
member variable var;
more member variables;
public StructureOfAProgram(){
Constructor for your instance variables'
public void Human(int age, int height, int weight, String name) {

public void Bob() {
Human bob = new Human(30, 5'6, 120, 'Bob');
if(bob.tired()) {
public void main(String[] args) {
/*if(args[1] == "bob") { Bob()........*/

You don't have a main method in your program! Every program needs a main method to start. Add your main method and your code should work fine.


This post has been edited by RCR: 30 July 2012 - 03:39 PM

Was This Post Helpful? -1
  • +
  • -

#4 macosxnerd101   User is offline

  • Games, Graphs, and Auctions
  • member icon

Reputation: 12316
  • View blog
  • Posts: 45,416
  • Joined: 27-December 08

Re: Error while trying to open update customer page

Posted 30 July 2012 - 05:13 PM

This is Java EE though, not Java SE. Java EE is for web and enterprise grade applications. It's a different platform than what you're referring to.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1