aspose file tools*
The moose likes Struts and the fly likes bean:define cannot instaniate new bean? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "bean:define cannot instaniate new bean?" Watch "bean:define cannot instaniate new bean?" New topic
Author

bean:define cannot instaniate new bean?

Dillon Bussert
Greenhorn

Joined: Aug 03, 2003
Posts: 1
<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

Joined: Feb 20, 2003
Posts: 10
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


Kay Casavant
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: bean:define cannot instaniate new bean?