• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

bean:define cannot instaniate new bean?

 
Dillon Bussert
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
<jsp:useBean id="basket" scope="session" class="BasketBean"/>
Rigth now I'm using this jsp tag to access the basket bean, which may not exist and it correctly creates a new one and places it into the session if necessary
I'm attempting to replace my code with struts tags so I want to use this
<bean:define id="basketList" name="basket" scope="session" type="BasketBean"/>
But everytime I get an Exception:
Cannot find bean basket in scope session' javax.servlet.ServletException..
This expected behavior since I know it doesn't exist in the session yet. The struts docs say bean:define "Unconditionally creates (or replaces) a bean under the specified identifier." But that's not what's happening here. How can I make the define tag create the the bean when it doesn't already exist?
[ August 04, 2003: Message edited by: Dillon Bussert ]
 
Kay Casavant
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I believe the "scope" parameter is to be used to indicate the scope where a bean already exists. Since you have not already placed the bean in this scope elsewhere in your app, this would explain the error message you are getting. However, there is a "toScope" parameter to indicate the scope where you intend to place a bean. It sounds like you should try this.
Perhaps you already know of this but I will place the Struts tag user guide url here anyway:
http://jakarta.apache.org/struts/userGuide/struts-bean.html#define
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic