File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Struts and the fly likes problems with bean:write Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "problems with bean:write" Watch "problems with bean:write" New topic

problems with bean:write

Mike Phillip
Ranch Hand

Joined: Dec 05, 2007
Posts: 37
Hi there,

I have a form (MyForm) that has a bean (Car). The Action (MyAction) sets the value of the car property.

Then I want to show in the .jsp file the properties inside the Car bean (model, year...)

after the action sets the property the jsp has the following:

<logic resent name="myForm" property="car">
Car model <bean:write name="car" property="model"/><br>
</logic resent>

but it doesn't works, says that the bean car is not present.

When I do

<logic resent name="myForm" property="car">
Car model <bean:write name="myForm" property="car"/><br>
</logic resent>

it prints the car.toString

I need to get the car and then print its properties.

any help?

Jeanne Boyarsky
author & internet detective

Joined: May 26, 2003
Posts: 33132

It's a two step process. First get a reference to the car:
<bean:define id="myCar" name="myForm" property="car" />

Then print out the model:
<bean:write name="car" property="model" />

[OCA 8 book] [Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Other Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, TOGAF part 1 and part 2
Merrill Higginson
Ranch Hand

Joined: Feb 15, 2005
Posts: 4864
Another option is to use "dot" notation. Example:

This will cause Struts to perform the following method calls:

[ May 03, 2008: Message edited by: Merrill Higginson ]

Consultant, Sima Solutions
Mike Phillip
Ranch Hand

Joined: Dec 05, 2007
Posts: 37
thanks guys, I'll try that.

best regards
I agree. Here's the link:
subject: problems with bean:write
It's not a secret anymore!