What is the exception this code is throwing. ?
-----Original Message-----
From: A mailing list for discussion about Sun Microsystem's Java Servlet
API Technology. [mailto:[EMAIL PROTECTED]]On Behalf Of
Daniel Liu
Sent: Friday, February 16, 2001 6:45 AM
To: [EMAIL PROTECTED]
Subject: Problem: share objects
I have some trouble in using the methods: getAttribute and
setAttribute.
A code segment of the method init() in my servlet as below:
/**************************************************************
ServletContext sc = getServletContext();
// Part 1
String test = (String) sc.getAttribute("test");
if (test == null ) {
test = new String("test");
sc.setAttribute("test", test);
}
// Part 2
ShoppingCartDB sdb =
(ShoppingCartDB) sc.getAttribute("ShoppingCartDB");
if (db.empty()) {
sdb = new ShoppingCartDB();
sc.setAttribute("ShoppingCartDB", sdb);
}
//.....
************************************************************/
the program throw an exception when execute Part 2. I do not see
any difference between Part 1 and Part 2.
Please help. Thanks.
----------------------
Daniel Liu
MONTAGE eIntegration(tm) Inc.
Tel: (613) 820-0080 x500
[EMAIL PROTECTED]
___________________________________________________________________________
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
___________________________________________________________________________
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