Results 1 to 2 of 2
Thread: session object
- 03-30-2008, 09:25 PM #1
Member
- Join Date
- Mar 2008
- Posts
- 1
- Rep Power
- 0
session object
HI All
I have created an object as follows:
package cart;
public class CartItem implements java.io.Serializable
{
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
- 06-23-2008, 12:45 AM #2
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:
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.Java Code:Vector victor = new Vector(); for( item count) { victor.add( new CartItem(Price, Customer, ShipDate); }
Similar Threads
-
Operator < cannot be applied to java.lang.Object, Object
By Albert in forum Advanced JavaReplies: 2Last Post: 11-26-2010, 02:12 AM -
problems with assigning a value to object session
By osval in forum New To JavaReplies: 1Last Post: 08-06-2007, 11:10 PM -
Creating object of Type Object class
By venkatv in forum New To JavaReplies: 3Last Post: 07-17-2007, 03:33 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks