Jere Robinson wrote:
>
> Hey guys, little 'ol me has been put on as head of my ISP's Java Servlet
> shopping cart project. I have a question about the HttpSession method
> getValue. It is supposed to return the object to which the String value
> parameter (name) points, but when I try the following:
>
> cartitem A = new cartitem();
> A.putName("Bar of Soap");
> A.putPrice(150);
> A.putQuantity(1);
>
> session.putValue(A.getName(),A);
> cartitem B = new cartitem();
> B = session.getValue(A.getName());
>
> It chokes on ' B = session.getValue(A.getName()); ' at compile time,
> telling me I need to cast it:
>
> CartTest.java:31: Incompatible type for =. Explicit cast needed to
> convert java.lang.Object to cartitem.
> B = session.getValue(A.getName());
> ^
> What do I need to get this to work?
> Oh, I need to overload the = operator in my cartitem class, don't I?
> I'll send this in case I'm going down the wrong path. Even if I'm
> right, how do we overload operators in Java?
>
> Thanks in advance!
> Jere
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html