• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Accessing ActionForm instances from JSP

 
Justin Chu
Ranch Hand
Posts: 209
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How do I access ActionForm instances from JSP?
For now, in execute(), I manually save a reference into session scope, which is not the best way of doing it.
// execute()
// Put in session to be accessible by JSP page.
req.getSession().setAttribute("nameOfFormBeanIManuallyAddedToSession", editForm);
<logic:equal name="nameOfFormBeanIManuallyAddedToSession" property="userId" value="-1">
No user is chosen
</logic>
The above serves the purpose, but what is a better way of doing it?
[ December 19, 2002: Message edited by: Chu Tan ]
 
Junilu Lacar
Bartender
Posts: 7480
50
Android Eclipse IDE IntelliJ IDE Java Linux Mac Scala Spring Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Use the logical name assigned to the form in struts-config.xml:
<!-- struts-config.xml -->
<form-bean name="foo" type="com.abc.FooForm">

<!-- in your jsp -->
<logic:equal name="foo" ... >
[ December 19, 2002: Message edited by: Junilu Lacar ]
 
Justin Chu
Ranch Hand
Posts: 209
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks That's clean enough for me.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic