aspose file tools*
The moose likes Struts and the fly likes Accessing ActionForm instances from JSP Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Accessing ActionForm instances from JSP" Watch "Accessing ActionForm instances from JSP" New topic
Author

Accessing ActionForm instances from JSP

Justin Chu
Ranch Hand

Joined: Apr 19, 2002
Posts: 209
    
    1
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

Joined: Feb 26, 2001
Posts: 4462
    
    6

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 ]

Junilu - [How to Ask Questions] [How to Answer Questions]
Justin Chu
Ranch Hand

Joined: Apr 19, 2002
Posts: 209
    
    1
thanks That's clean enough for me.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Accessing ActionForm instances from JSP