Results 1 to 2 of 2

Thread: session object

  1. #1
    5alive is offline Member
    Join Date
    Mar 2008
    Rep Power

    Default session object

    HI All

    I have created an object as follows:

    package cart;

    public class CartItem implements

    private static int StockID;
    private static String ProdName;
    private static int price;
    private Vector Items;

    public CartItem(int StockID, String Name, int pPrice)
    StockID = StockID;
    ProdName = Name;
    price = pPrice;

    public ShoppingCart()
    Items = new Vector(StockID, Name, Price);

    public String getName()
    return ProdName;

    public int getStockID()
    return StockID;

    public int getPrice()
    return price;


    Does anyone know if that the vector object is
    a) correct
    b) can it now be passed to the session using
    cart.setAttribute(product, Items);

    Thanks to all

  2. #2
    Nicholas Jordan's Avatar
    Nicholas Jordan is offline Senior Member
    Join Date
    Jun 2008
    Rep Power

    Default I doubt it would compile.

    Maybe, if you are lucky, but I seriously doubt this will even compile. What you should do, and I have consdered this problem until I am Struck Zombie on it, is put the items in the Vector in a loop. The items all have to be the same type. We cannot have an Apple, a String and a TicketToRide all be in the same vector.

    Somewhere else you could keep a vector of shopping cart items:
    Java Code:
    Vector victor = new Vector();
    for( item count)
        victor.add( new CartItem(Price, Customer, ShipDate);
    This code is so badly abbreviated that they will laugh at me but what we are trying to do is answer your question, not worry about my comfort.

Similar Threads

  1. Replies: 2
    Last Post: 11-26-2010, 03:12 AM
  2. Replies: 1
    Last Post: 08-07-2007, 12:10 AM
  3. Creating object of Type Object class
    By venkatv in forum New To Java
    Replies: 3
    Last Post: 07-17-2007, 04:33 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts