• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

bean:define cannot instaniate new bean?

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic