• 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
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

Where's the best place to declare all the beans?

 
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I am new to Struts, and tried to use as much as Structs tag as possible in my jsp. One problem confuses me is where to define all the beans that my jsp need to access? In the past, I used to have some java code in the jsp to declare all the beans to be accessed, but in the sturcts framework, this seems not to be the way. Do anyone have a good approach? Thanks a lot!
 
pie sneak
Posts: 4727
Mac VI Editor Ruby
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well, typically your bean in Struts is the ActionForm and that is declared in the ActionMappings of the struts-config.xml
 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If I understand your question correctly, you can use bean define tag to declare your bean.

 
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I agree use the <bean efine /> tag. Or the <c:set /> tag in jstl.
 
Stefan Bell
Ranch Hand
Posts: 82
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I agree use the <bean efine /> tag. Or the <c:set /> tag in jstl.
 
JW Li
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
K and Stefan, thanks for the help! I will look more into bean and jstl tags.

Marc, sometimes, I want to access beans that are not defined in ActionForm or the action doesn't have a corresponding form, that's when I have the problem to access the beans from jsp. But thanks anyway!
 
Ranch Hand
Posts: 1312
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
In my work, i create my JavaBean for use in each jsp page and keep bean into request/session scope.

This solution you not config in struts-config.xml...
 
Please enjoy this holographic presentation of our apocalyptic dilemma right after this tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic