• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Knute Snortum
  • Paul Clapham
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Frits Walraven
Bartenders:
  • Ganesh Patekar
  • Tim Holloway
  • salvin francis

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

 
Ranch Hand
Posts: 33
  • Mark post as helpful
  • send pies
  • 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 Ruby VI Editor
  • Mark post as helpful
  • send pies
  • 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
  • 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
  • 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
  • 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
  • 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
  • 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...
 
What does a metric clock look like? I bet it is nothing like this tiny ad:
ScroogeXHTML - small and flexible RTF to HTML converter library
https://coderanch.com/t/710903/ScroogeXHTML-RTF-HTML-XHTML-converter
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!