Hi All!

I've been working on a simple MVC style / struts web application which will allow a user to view a product database and have the option to update a record. The initial index.jsp page works and forwards to the right locations, the update page displays but is producing another error but that is not within the scope of this question.

When i click to view the product database, I get the following error in Apache Tomcat (note I am using built in Tomcat within Netbeans 5.0)

I have done searches on the Web and they say that this method is being called recursively? However, when I run a System.out.println to show the SQL query it displays fine with no problems. Also it is not showing errors with other methods, so I assume that it is stuck on this getPid method.

I hope someone can shed some light on this matter.

Thanks

Apache Tomcat Error

HTTP Status 500 -

type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
javax.servlet.ServletException org.apache.jasper.runtime.PageContextImpl.doHandlePageException(PageContextImpl.java:848) org.apache.jasper.runtime.PageContextImpl.handlePageException(PageContextImpl.java:781) org.apache.jsp.viewprod_jsp._jspService(viewprod_jsp.java:112) org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:97) javax.servlet.http.HttpServlet.service(HttpServlet.java:802) org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:322) org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:291) org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241) javax.servlet.http.HttpServlet.service(HttpServlet.java:802) org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:362) org.apache.struts.action.ActionServlet.processForward(ActionServlet.java:1848) org.apache.struts.action.ActionServlet.process(ActionServlet.java:1569) org.apache.struts.action.ActionServlet.doGet(ActionServlet.java:492) javax.servlet.http.HttpServlet.service(HttpServlet.java:689) javax.servlet.http.HttpServlet.service(HttpServlet.java:802) org.netbeans.modules.web.monitor.server.MonitorFilter.doFilter(MonitorFilter.java:362)
root cause
java.lang.StackOverflowError elecstore.UpdateBean.getPid(UpdateBean.java:16) elecstore.UpdateBean.getPid(UpdateBean.java:16) elecstore.UpdateBean.getPid(UpdateBean.java:16) elecstore.UpdateBean.getPid(UpdateBean.java:16) elecstore.UpdateBean.getPid(UpdateBean.java:16) elecstore.UpdateBean.getPid(UpdateBean.java:16) elecstore.UpdateBean.getPid(UpdateBean.java:16) elecstore.UpdateBean.getPid(UpdateBean.java:16) elecstore.UpdateBean.getPid(UpdateBean.java:16) elecstore.UpdateBean.getPid(UpdateBean.java:16) elecstore.UpdateBean.getPid(UpdateBean.java:16) elecstore.UpdateBean.getPid(UpdateBean.java:16) elecstore.UpdateBean.getPid(UpdateBean.java:16) elecstore.UpdateBean.getPid(UpdateBean.java:16) elecstore.UpdateBean.getPid(UpdateBean.java:16) elecstore.UpdateBean.getPid(UpdateBean.java:16) elecstore.UpdateBean.getPid(UpdateBean.java:16) elecstore.UpdateBean.getPid(UpdateBean.java:16) elecstore.UpdateBean.getPid(UpdateBean.java:16) elecstore.UpdateBean.getPid(UpdateBean.java:16) elecstore.UpdateBean.getPid(UpdateBean.java:16) elecstore.UpdateBean.getPid(UpdateBean.java:16) elecstore.UpdateBean.getPid(UpdateBean.java:16) elecstore.UpdateBean.getPid(UpdateBean.java:16) elecstore.UpdateBean.getPid(UpdateBean.java:16) elecstore.UpdateBean.getPid(UpdateBean.java:16) elecstore.UpdateBean.getPid(UpdateBean.java:16) elecstore.UpdateBean.getPid(UpdateBean.java:16) elecstore.UpdateBean.getPid(UpdateBean.java:16) elecstore.UpdateBean.getPid(UpdateBean.java:16) elecstore.UpdateBean.getPid(UpdateBean.java:16) elecstore.UpdateBean.getPid

.... THIS CONTINUES TILL THE END OF THE PAGE ....

(UpdateBean.java:16) elecstore.UpdateBean.getPid(UpdateBean.java:16) elecstore.UpdateBean.getPid(UpdateBean.java:16) elecstore.UpdateBean.getPid(UpdateBean.java:16) elecstore.UpdateBean.getPid(UpdateBean.java:16) elecstore.UpdateBean.getPid(UpdateBean.java:16) elecstore.UpdateBean.getPid
(UpdateBean.java:16)
note The full stack trace of the root cause is available in the Apache Tomcat/5.5.9 logs.
Apache Tomcat/5.5.9


UpdateBean.java

package elecstore;
import java.sql.*;
import java.sql.Date;
import java.text.*;
import java.util.*;
import javax.naming.*;
import javax.sql.*;
import elecstore.*;
public class UpdateBean {
 
 Products p = null;
 
 public int getPid() {
  return getPid();
  }
 
 public void setPid(int pid) {
  setPid(pid);
  }
 
 public String getProdId() {
  return getProdId();
  }
 
 public void setProdId (String prodId) {
  setProdId(prodId);
  }
 
 public String getProdType() {
  return getProdType();
  }
 
 public void setProdType (String prodType) {
  setProdType(prodType);
 }
 
 public String getMan() {
  return getMan();
  }
 
 public void setMan (String man) {
  setMan(man);
 }
 
 public String getProduct() {
  return getProduct();
  }
 
 public void setProduct (String product) {
  setProduct(product);
 }
 
 public int getQty() {
  return getQty();
  }
 
 public void setQty (int qty) {
  setQty(qty);
  }
 
 public String getPrice() {
  return getPrice();
  }
 
 public void setPrice (String price) {
  setPrice(price);
  }
 
 public Date getDateAdded() {
  return getDateAdded();
  }
 
 public void setDateAdded (Date dateAdded) {
  setDateAdded(dateAdded);
 }
 
 public boolean getStockOnOrder() {
  return getStockOnOrder();
  }
 
 public void setStockOnOrder (boolean stockOnOrder) {
  setStockOnOrder(stockOnOrder);
 }
 
 public UpdateBean() throws SQLException, NamingException
 {
  String jdbcDriver = "sun.jdbc.odbc.JdbcOdbcDriver";
     String dbURL = "jdbc:odbc:qc310";
     String user = "Lukas";
     String password = "12345";
 
  System.out.println("TEST HERE - UpdateBean");
  Connection con = null;
  Connection con2 = null;
                Statement select = null;
                PreparedStatement updateProduct = null;
                ResultSet rs = null;;
  ResultSet rs2 = null;
 
  try {
   System.out.println("TEST HERE - making database connection...");
   // Load in the JDBC-ODBC driver
                        Class.forName(jdbcDriver);
 
                        // Create connection
                        con = DriverManager.getConnection(dbURL, user, password);
                        System.out.println("\n...Connection to Electronic Store Database Established\n");
                        System.out.println("TEST HERE - database connection ok...");
 
                        Statement stmt = con.createStatement();
                        System.out.println("SQL Statement created...");
   rs = stmt.executeQuery("SELECT * FROM Elecstore");
 
 
      while (rs.next()) { 
 
                        p = new Products(rs.getInt(1),
                                         rs.getString(2), 
                                         rs.getString(3), 
                                         rs.getString(4), 
                                         rs.getString(5), 
                                         rs.getInt(6), 
                                         rs.getString(7), 
                                         rs.getDate(8), 
                                         rs.getBoolean(9));  
 
         System.out.println(p.getPid() + " " + p.getProdId() + "\t" + p.getProdType() + "\t\t" + p.getMan() + "\t\t" + p.getProduct() + "\t\t\t" + p.getPrice() + "\t\t\t" + p.getQty() + "\t\t\t" + p.getDateAdded() + "\t\t\t" + p.getStockOnOrder());
                        }
                        rs.close();  
 
  }
 
  catch(Exception e) {
   e.printStackTrace();;
   }
 
 
  try {
 
   Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
   con2 = DriverManager.getConnection("jdbc:odbc:qc310");
   updateProduct = con.prepareStatement("UPDATE Elecstore SET Qty = ?, Price = ? WHERE ProductID = ?");
 
    updateProduct.setInt (1, p.getQty());
    updateProduct.setString (2, p.getPrice());
    updateProduct.setString (3, p.getProdId());
 
    updateProduct.executeUpdate();
 
   if (!rs2.next())
    throw new SQLException("Missing Products data row");
 
  }
 
  catch(Exception e) {
   System.out.println(e);
  }
 
  finally {
   try { rs.close(); } catch (Exception ex) {}
   try { con.close(); } catch (Exception ex) {}
  }
 }
}

Products.java

package elecstore;
import java.sql.Date;
 
/**
 * This domain object represents a player in a sports league.
 * The data attributes are all package-private to allow access to them
 * in the {@link RegisterService} class.
 */
public class Products {
  int pid;
  int qty;
  String prodId;
  String prodType;
  String man;
  String product;
  String price;
  Date dateAdded;
  boolean stockOnOrder;
 
  /**
   * This is the constructor.  It is package-private to prevent
   * misuse.  The {@link RegisterServer} method should be used to
   * create a new player object.
   */
  //Product(String prodID) {
  //  this(+1, "", prodID, "", "", "", "");
  //}
  /**
   * This is the full constructor.
   */
 
   Products(int pid, String prodId, String prodType, String man,
         String product, int qty, String price, Date dateAdded, boolean stockOnOrder) {
 
    this.pid = pid;
    this.prodId = prodId;
    this.prodType = prodType;
    this.man = man;
    this.product = product;
    this.qty = qty;
    this.price = price;
    this.dateAdded = dateAdded;
    this.stockOnOrder = stockOnOrder;
  }
  public int getQty() {
  return qty;
   }
 
  public void setQty(int qty){
 this.qty = qty;
 }
 
  public int getPid() {
 return pid;
   }
 
  public void setPid(int pid){
 this.pid = pid;
 }
 
  public String getProdId() {
 return prodId;
   }
 
  public void setProdId(String prodId){
 this.prodId = prodId;
 }
 
  public String getProdType(){
 return prodType;
 }
 
  public void setProdType(){
 this.prodType = prodType;
 }
 
  public String getMan(){
 return man;
 }
  public void setMan(String man){
 this.man = man;
 }
  public String getProduct(){
 return product;
 }
  public void setProduct(String product){
 this.product = product;
 }
 
  public String getPrice(){
 return price;
   }
 
  public void setPrice(String price){
 this.price = price;
 }
  public Date getDateAdded() {
  return dateAdded;
   }
 
  public void setDateAdded(Date dateAdded){
 this.dateAdded = dateAdded;
 }
  public boolean getStockOnOrder() {
  return stockOnOrder;
   }
 
  public void setStockOnOrder(boolean stockOnOrder){
 this.stockOnOrder = stockOnOrder;
 }
}

ActionUpdate.java

package elecstore;
import java.io.*;
import java.sql.*;
import java.text.*;
import javax.naming.*;
import javax.servlet.*;
import javax.servlet.http.*;
import org.apache.struts.action.*;
import elecstore.*;
import elecstore.UpdateBean;
public class ActionUpdate extends Action
{
 public ActionForward perform(ActionMapping mapping, ActionForm actionForm,
   HttpServletRequest request, HttpServletResponse response)
   throws IOException, ServletException {
 
  ActionErrors errors = null;
  try {
   UpdateBean update = new UpdateBean();
   UpdateForm form = (UpdateForm)actionForm;
 
   System.out.println(form.getProdId());
   update.setProdId(form.getProdId());
 
   System.out.println(form.getQty());
   update.setQty(form.getQty());
 
   System.out.println(form.getPrice());
   update.setPrice(form.getPrice());
 
   request.setAttribute("prodId",update.getProdId());
   request.setAttribute("qty", new Integer(update.getQty()));
   request.setAttribute("price",update.getPrice());
      return mapping.findForward("update");
  }
 
  catch (NamingException ex) {
         errors = new ActionErrors();
            errors.add("database", new ActionError("errors.naming.error"));
  }
  catch (SQLException ex) {
         errors = new ActionErrors();
            errors.add("database", new ActionError("errors.database.error"));
  }
  catch (Exception e) {
   System.out.println("AN OTHER" + e);
  }
  saveErrors(request,errors);
  return mapping.findForward("error");
 }
}

UpdateForm.java

package elecstore;
import javax.servlet.http.*;
import org.apache.struts.action.*;
public class UpdateForm extends ActionForm {
    private String prodId;
    private String price;
    private int qty;
 
 public void setProdId (String prodId) { this.prodId = prodId; }
 public String getProdId () { return prodId; }
 
 public void setPrice (String price) { this.price = price; }
 public String getPrice () { return price; }
 public void setQty (int qty) { this.qty = qty; }
 public int getQty () { return qty; }
 public void reset(ActionMapping mapping, HttpServletRequest request) {
    prodId = null;
 price = null;
 qty = 0;
    }
 public ActionErrors validate(ActionMapping mapping,
                                 HttpServletRequest request) {
 
        ActionErrors errors = new ActionErrors();
        if (prodId == null)
            errors.add("prodId", new ActionError("errors.prodId.required"));
 
  else if (prodId.length() == 0)
             errors.add("prodId", new ActionError("errors.prodId.novalue"));
  else if (price == null)
       errors.add("price", new ActionError("errors.price.required"));
 
  else if (price.length() == 0)
              errors.add("price", new ActionError("errors.price.novalue"));
 
  else if (qty == 0)
       errors.add("qty", new ActionError("errors.qty.required"));
 
  return errors;
  }
 
 }

UPDATE

Here are the Jsp files, after some debugging both pages display, just when I add in the jsp:getproperty then I get the StackOverflowError.

How can i get the JSP to use these values but not cause this Overflow error?

index.jsp

<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<html:html locale="true">
<head>
<title>Electronic Store | Admin</title>
<link href="qc310.css" rel="stylesheet" type="text/css">
</head>
<body>
<table border='0' cellspacing='0' cellpadding='0' width='600'>
<tr>
    <td colspan='2' bgcolor='#CCCCCC' align='center'><b>Electronic Store</b></td>
</tr>
</table>
  <br /><html:link page='/viewprod.do'>View product list</html:link> 
  <br /><html:link page='/update.do'>Update product</html:link>
 <br />
 <br />
 <table width="600" border="0">
      <tr>
        <th scope="row">______________________________________________________</th>
      </tr>
</table>
 <table border='0' cellspacing='0' cellpadding='0' width='600'>
<tr>
    <td colspan='2' align='center'><div align="left"><span class="copyright">&copy; 2006 Lukas Winn</span><br />
   <br />
    </div></td>
</tr>
</table>
    <p>&nbsp;</p>
</body>
</html:html>
</html>

viewprod.jsp (without jsp:getproperty set)

<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<jsp:useBean id="select" class="elecstore.SelectBean">
  <jsp:setProperty name="select" property="pid" />
  <jsp:setProperty name="select" property="prodId" />
  <jsp:setProperty name="select" property="prodType" />
  <jsp:setProperty name="select" property="man" />
  <jsp:setProperty name="select" property="product" />
  <jsp:setProperty name="select" property="qty" />
  <jsp:setProperty name="select" property="price" />
  <jsp:setProperty name="select" property="dateAdded" />
  <jsp:setProperty name="select" property="stockOnOrder" /> 
</jsp:useBean>
<html:html>
  <head>
    <title>Electronic Store | View Product Database</title>
    <link href="qc310.css" rel="stylesheet" type="text/css">
  </head>
  <body>
  <h1>Product Database</H1>
    <h2>
   Products:
 
 
    </h2>
    <P><html:link page="/home.do">back to main...</html:link></p>
  </body>
</html:html>

viewprod.jsp (with jsp:getproperty set)
(THIS IS WHERE THE STACKOVERFLOW OCCURS...)

<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<jsp:useBean id="select" class="elecstore.SelectBean">
  <jsp:setProperty name="select" property="pid" />
  <jsp:setProperty name="select" property="prodId" />
  <jsp:setProperty name="select" property="prodType" />
  <jsp:setProperty name="select" property="man" />
  <jsp:setProperty name="select" property="product" />
  <jsp:setProperty name="select" property="qty" />
  <jsp:setProperty name="select" property="price" />
  <jsp:setProperty name="select" property="dateAdded" />
  <jsp:setProperty name="select" property="stockOnOrder" /> 
</jsp:useBean>
<html:html>
  <head>
    <title>Electronic Store | View Product Database</title>
    <link href="qc310.css" rel="stylesheet" type="text/css">
  </head>
  <body>
  <h1>Product Database</H1>
    <h2>
   Products:
         <jsp:getProperty name="update" property="pid" /><br />
         <jsp:getProperty name="update" property="prodId" /><br /> 
  <jsp:getProperty name="update" property="prodType" /><br />
  <jsp:getProperty name="update" property="man" /><br />
  <jsp:getProperty name="update" property="product" /><br />
  <jsp:getProperty name="update" property="qty" /><br />
  <jsp:getProperty name="update" property="price" /><br />
  <jsp:getProperty name="update" property="dateAdded" /><br />
  <jsp:getProperty name="update" property="stockOnOrder" /><br />
 
    </h2>
    <P><html:link page="/home.do">back to main...</html:link></p>
  </body>
</html:html>

update.jsp

<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<html:html locale="true">
<head>
<title>Electronic Store | Update Product</title>
<link href="qc310.css" rel="stylesheet" type="text/css">
</head>
<body>
<html:form action="/update.do">
<br /><br /><b>Electronic Store | Update Database</b><br /><br />  
  Please enter the updated information and then click on update to make the changes to the database<br />
  <form action="update.jsp" method="post" name="updateForm" id="updateForm">
    <table width="300" border="0">
      <tr>
        <th width="132" scope="row"><div align="left">Product ID</div></th>
        <td width="147"><html:text property="prodId" /></td>
      </tr>
      <tr>
        <th scope="row"><div align="left">Qty</div></th>
        <td><html:text property="qty" /></td>
      </tr>
      <tr>
        <th scope="row"><div align="left">Price</div></th>
        <td><html:text property="price" /></td>
      </tr>
      <tr>
        <th colspan="2" scope="row"><div align="left"><br />
              <html:submit> Update</html:submit>
        </div></th>
      </tr>
      <tr>
        <th colspan="2" scope="row">_____________________________________</th>
      </tr>
    </table>
    </form>
  <br />
  </html:form>
    <html:errors/>
    <logic:present name="prodId">
    Output
  <br /><bean:write name="prodId"/>
     <br /><bean:write name="price"/>
  <br /><bean:write name="qty"/>
    </logic:present>
 <html:link page="/home.do">back to main... </html:link><br /><br />
 <table width="300" border="0">
      <tr>
        <th scope="row">_____________________________________</th>
      </tr>
      <tr>
        <th scope="row"><div align="left"><span class="copyright">&copy; 2006 Lukas Winn</span></div></th>
      </tr>
    </table>
 <br />
 <br />
   <br />
</body>
</html:html>

Uhm ...

Look at your UpdateBean code. All of your get/set routines do
nothing but call themselves. They should actually return/set something
from the actual Bean, not just simply call themselves.

When all they do is call themselves, you have a classic case of infinite
recursion.

I assume you meant to call routines of the same name from the p
instance. If this is the case, you forgot to put "p." in front of the
subroutine calls inside of your set/get routines.

Thanks for that advice, yes I changed that in my code and I got a result, but it is only returning the last record information. Even though the System.out.println displays all records. How would you do it for displaying in the JSP? As I said only the last record data is being shown?

Any ideas?

Selectbean.java

/*
 * SelectBean.java
 *
 * Created on 28 April 2006, 00:28
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */
package elecstore;
import java.sql.*;
import java.sql.Date;
import java.text.*;
import java.util.*;
import javax.naming.*;
import javax.sql.*;
import elecstore.*;
public class SelectBean {
 
    Products p = null;
 
 public int getPid() {
  return p.getPid();
  }
 
 public void setPid(int pid) {
  p.setPid(pid);
  }
 
 public String getProdId() {
  return p.getProdId();
  }
 
 public void setProdId (String prodId) {
  p.setProdId(prodId);
  }
 
 public String getProdType() {
  return p.getProdType();
  }
 
 public void setProdType (String prodType) {
  p.setProdType(prodType);
 }
 
 public String getMan() {
  return p.getMan();
  }
 
 public void setMan (String man) {
  p.setMan(man);
 }
 
 public String getProduct() {
  return p.getProduct();
  }
 
 public void setProduct (String product) {
  p.setProduct(product);
 }
 
 public int getQty() {
  return p.getQty();
  }
 
 public void setQty (int qty) {
  p.setQty(qty);
  }
 
 public String getPrice() {
  return p.getPrice();
  }
 
 public void setPrice (String price) {
  p.setPrice(price);
  }
 
 public Date getDateAdded() {
  return p.getDateAdded();
  }
 
 public void setDateAdded (Date dateAdded) {
  p.setDateAdded(dateAdded);
 }
 
 public boolean getStockOnOrder() {
  return p.getStockOnOrder();
  }
 
 public void setStockOnOrder (boolean stockOnOrder) {
  p.setStockOnOrder(stockOnOrder);
 }
 
    /** Creates a new instance of SelectBean */
    public SelectBean() throws SQLException, NamingException
    {
        String jdbcDriver = "sun.jdbc.odbc.JdbcOdbcDriver";
    String dbURL = "jdbc:odbc:qc310";
    String user = "Lukas";
    String password = "12345";
 
 System.out.println("TEST HERE - SelectBean");
 Connection con = null;
        Statement select = null;
        ResultSet rs = null;
 
        try {
   System.out.println("TEST HERE - making database connection...");
   // Load in the JDBC-ODBC driver
                        Class.forName(jdbcDriver);
 
                        // Create connection
                        con = DriverManager.getConnection(dbURL, user, password);
                        System.out.println("\n...Connection to Electronic Store Database Established\n");
                        System.out.println("TEST HERE - database connection ok...");
 
                        Statement stmt = con.createStatement();
                        System.out.println("SQL Statement created...");
   rs = stmt.executeQuery("SELECT * FROM Elecstore");
 
      while (rs.next()) { 
 
                        p = new Products(rs.getInt(1),
                                         rs.getString(2), 
                                         rs.getString(3), 
                                         rs.getString(4), 
                                         rs.getString(5), 
                                         rs.getInt(6), 
                                         rs.getString(7), 
                                         rs.getDate(8), 
                                         rs.getBoolean(9));  
 
         System.out.println(p.getPid() + " " + p.getProdId() + "\t" + p.getProdType() + "\t\t" + p.getMan() + "\t\t" + p.getProduct() + "\t\t\t" + p.getPrice() + "\t\t\t" + p.getQty() + "\t\t\t" + p.getDateAdded() + "\t\t\t" + p.getStockOnOrder());
                        }
  System.out.print("After Select query has been run...");
  }
 
  catch(Exception e) {
   e.printStackTrace();;
   }
 
                finally {
                                try { rs.close(); } catch (Exception ex) {}
                                try { con.close(); } catch (Exception ex) {}
                } 
 
    }
 
}

viewprod.jsp

<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<jsp:useBean id="select" class="elecstore.SelectBean">
  <jsp:setProperty name="select" property="pid" />
  <jsp:setProperty name="select" property="prodId" />
  <jsp:setProperty name="select" property="prodType" />
  <jsp:setProperty name="select" property="man" />
  <jsp:setProperty name="select" property="product" />
  <jsp:setProperty name="select" property="qty" />
  <jsp:setProperty name="select" property="price" />
  <jsp:setProperty name="select" property="dateAdded" />
  <jsp:setProperty name="select" property="stockOnOrder" /> 
</jsp:useBean>
<html:html>
  <head>
    <title>Electronic Store | View Product Database</title>
    <link href="qc310.css" rel="stylesheet" type="text/css">
  </head>
  <body>
  <h1>Product Database</H1>
    <h2>
   Products:
          <jsp:getProperty name="select" property="pid" /><br />
          <jsp:getProperty name="select" property="prodId" /><br /> 
   <jsp:getProperty name="select" property="prodType" /><br />
   <jsp:getProperty name="select" property="man" /><br />
   <jsp:getProperty name="select" property="product" /><br />
   <jsp:getProperty name="select" property="qty" /><br />
   <jsp:getProperty name="select" property="price" /><br />
   <jsp:getProperty name="select" property="dateAdded" /><br />
   <jsp:getProperty name="select" property="stockOnOrder" /><br />
 
 
    </h2>
    <P><html:link page="/home.do">back to main...</html:link></p>
  </body>
</html:html>

In your while (rs.next( ) ) loop, you are recreating "p" everytime.
So, only the last line is available. You would need to use some sort of
Collection (ArrayList probably) to be able to store all the records, but
then, you would also have to figure out a way determine which record
you wish to return the data for. Also, your jsp is currently only set up
to show one record as well. Building the table you want is going take
a bit more planning. Look into JSTL loops and, probably, a more
direct database query.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.