This week's book giveaway is in the Android forum.
We're giving away four copies of Head First Android and have Dawn & David Griffiths on-line!
See this thread for details.
The moose likes Struts and the fly likes Calling a static method with a struts variable Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Head First Android this week in the Android forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Calling a static method with a struts variable" Watch "Calling a static method with a struts variable" New topic

Calling a static method with a struts variable

Frank Bueckert

Joined: Mar 23, 2006
Posts: 8
Not exactly sure how to go about this. I'm using the JFreeChart jar file to generate a dynamic image based on the data I'm using. That's all fine and dandy.
My problem is accessing a variable I'm defining in the action, and using it in a scriptlet to write an imagemap straight into the JSP.

This defines the variable for the JSP. That part works fine. However, when I try to use it in a scriptlet, it turns up as null.

I've tried using "info", "(org.jfree.chart.ChartRenderingInfo) info", and any other variations I can come up with. I know I'm doing something wrong, but I have no idea what.
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
You can't nest one Struts tag inside another.

change your <bean:define>tag to:

<bean:define id="info" type="org.jfree.chart.ChartRenderingInfo" scope="page" name="graphForm" property="info"/>

If you do this, your scriptlet should work.

You could also try getting the info bean directly from the ActionForm, as in:

[ July 18, 2006: Message edited by: Merrill Higginson ]

Consultant, Sima Solutions
I agree. Here's the link:
subject: Calling a static method with a struts variable
jQuery in Action, 3rd edition