troubleshooting Question

JSP - Edit table containing Beans / XML

Avatar of vandy02
vandy02Flag for United States of America asked on
13 Comments1 Solution504 ViewsLast Modified:
I am learning JSP and Java Beans with XML.  So far so good.   However, I would like to be able to edit the data in the table after I display it.  I would like to be able to select a stock in the table and have couple fields appear on the same page with the data from the table where I could then save it back to the table.  I would actually be changing the xml or Vector in this example. At least this is what I am thinking should happen

I am referring to adding this to the Sample 4-6

Sample 4:
package stocks;
import java.util.*;
public class PortfolioBean implements {
   private Vector portfolio = new Vector();
   public PortfolioBean() {
      portfolio.addElement(new Stock("SUNW",
       "Sun Microsystems", (float) 17.1));
      portfolio.addElement(new Stock("AOL",
       "America Online", (float) 51.05));
      portfolio.addElement(new Stock("IBM",
       "International Business Machines",
        (float) 116.10));
      portfolio.addElement(new Stock("MOT",
       "MOTOROLA", (float) 15.20));
   public Iterator getPortfolio() {
      return portfolio.iterator();
Sample 5:
package stocks;
public class Stock implements {
   private String symbol;
   private String name;
   private float price;
   public Stock(String symbol, String name,
    float price) {
      this.symbol = symbol; = name;
      this.price = price;
   public String getSymbol() {
      return symbol;
   public String getName() {
      return name;
   public float getPrice() {
      return price;
Sample 6: stocks.jsp
<%@ page contentType="text/xml" %>
<%@ page import="stocks.*" %>
<jsp:useBean id="portfolio" 
class="stocks.PortfolioBean" />
java.util.Iterator folio = 
Stock stock = null;
<?xml version="1.0" encoding="UTF-8"?>
  <% while (folio.hasNext()) { %>
    <% stock = (Stock); %>
      stock.getSymbol() %></symbol>
      stock.getName() %></name>
      stock.getPrice() %></price>
  <% } %>

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 13 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 13 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros