This discussion is archived
1 Reply Latest reply: Feb 4, 2010 8:48 AM by 843807 RSS

well can you tell how transfer a List eg. created as bean->jsp(view)

843807 Newbie
Currently Being Moderated
well can you tell how transfer a List eg. created as
   public List getLineList() {  // beans.OrderTotals
     return lineList;
    public static void addPlant(OrderPlantItem orderPlantItem) {
            lineList.add( orderPlantItem );
from bean to jsp or from bean to bean or from jsp call to bean, and appear contents on screen or populate a Table(db) ?
In a Shopping cart web app I must add lineItems first and after Order, to Tables in DB: LineItems and Orders respectively?
public String updateTables(OrderTotals OrderTotals2, List lineList2) {  // void
     String sqlCommand1= "INSERT INTO Customers VALUES('0011','"+this.getCustName()+"','"+this.getCustStreet()+"','"+this.getCustCity()+"','"+this.getCustState()+"','"+this.getCustZip()+"','2')" ;
     String sqlCommand2= "INSERT INTO Orders VALUES('1011','0011','"+new java.util.Date()+"','"+new java.util.Date()+"',"+OrderTotals2.getTotal()+","+OrderTotals2.getShipping()+","+OrderTotals2.getTax()+")" ;
     String url = "jdbc:odbc:plants"; //dsn plants
     String user="";
     String password="";
     try {
         ("jdbc:odbc:plants", user, password);
          //get statement object
      }catch (Exception exception)  {
   //return (exception.getMessage());
      } // end of catch
        finally {
      try {
//Object[] lineList2 = lineList5.toArray();
        for (int i = 0; i < lineList2.size(); i++)  //lineList2.length
          OrderPlantItem lineItem0 = (OrderPlantItem)lineList2.get(i);
          String sqlCommand3= "INSERT INTO OrderDetail VALUES('1011',"+i+1+","+lineItem0.getPlantID()+","+lineItem0.getQty()+","+lineItem0.getSubtotal()+")" ;
 } // end of try
<jsp:useBean id="add" scope="session" class="beans.AddOrder" />
<jsp:useBean id="AddChoosePlant" scope="session" class="beans.OrderTotals" />
  • 1. Re: well can you tell how transfer a List eg. created as bean->jsp(view)
    843807 Newbie
    Currently Being Moderated
    1)db Q

    in a for body that executes a query like above:
    must appear outside loop? is this above correct?

    2)Q:List object data appear in jsp(view) or enter in db-table(model) like cartItems in cart

    When I have a List obj contains cartItems objects (eg shopping cart) already populated in a javabean, and want to appear this data to the next jsp file(view) and then enter them in database table via next confirm.jsp that use a process bean(model), what to do to transfer this List Object?