This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
The moose likes Struts and the fly likes Session bean in Struts 2 Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Session bean in Struts 2" Watch "Session bean in Struts 2" New topic
Author

Session bean in Struts 2

Nigel King
Greenhorn

Joined: Mar 03, 2006
Posts: 29
Hi,

I'm relatively new to Struts 2 and am trying to create a session bean that will hold a list of manufacturers.
In a JSP using Struts 1 tags I might do something like

to set the bean from an already defined service bean.
Is there an equivalent in Struts 2? Or am I looking at another method of achieving the same?

Thanks in advance.
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

Well, I'm not convinced that kind of logic belongs in the JSP page. If you already have the manufacturers available then why not just do it in the action? IMO the view layer shouldn't be responsible for defining application-wide behavior.
Nigel King
Greenhorn

Joined: Mar 03, 2006
Posts: 29
Thanks, David. You make a good point.
I'll do it that way instead.
David Newton
Author
Rancher

Joined: Sep 29, 2008
Posts: 12617

(I should have answered the question anyway; the equivalent tag would be <s:set>, although to be honest I've never used it to do anything other than create action-scoped temporary variables.)
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Session bean in Struts 2