Struts - accessing the ActionForm bean in JSP

A

Agent86

Hi,

How do you access the ActionForm in the associated JSP (in java code)?

I know i can DISPLAY with:
<bean:write name="myform" property="myproperty"/>

but I would like to do something like:

<%= (myform.myIntProperty + 5) %>

Thanks !
 
D

Donkey Hottie

Agent86 said:
Hi,

How do you access the ActionForm in the associated JSP (in java code)?

I know i can DISPLAY with:
<bean:write name="myform" property="myproperty"/>

but I would like to do something like:

<%= (myform.myIntProperty + 5) %>

Thanks !

Maybe like this.

<bean:define id="myIntProperty" name="myForm" property="myIntProperty"
type="java.lang.Integer" />

<%= myIntProperty.intValue() + 5 %>
 
D

Donkey Hottie

Maybe like this.

<bean:define id="myIntProperty" name="myForm" property="myIntProperty"
type="java.lang.Integer" />

<%= myIntProperty.intValue() + 5 %>

This should work better

<bean:define id="myform" name="myForm" type="mypackage.MyForm" />

<%= (myform.myIntProperty + 5) %>

The point being that there is no java object without defining it somehow.
The form is request.getAttribyte("myform") or session.getAttribute
("myform")
 
L

Lew

This should work better

<bean:define id="myform" name="myForm" type="mypackage.MyForm" />

<%= (myform.myIntProperty + 5) %>

The point being that there is no java object without defining it somehow.
The form is request.getAttribyte("myform") or session.getAttribute
("myform")

<c:eek:ut value="${myForm.myProperty + 5}" />
 
A

Agent86

One More question:

<c:eek:ut value="${myForm.intDummy + 5}" /> works fine with an integer
property.

What if I want to transform a String ?

<c:eek:ut value="${myForm.strDummy + "__"}" /> does not work.

How should I do that ?
 
T

Tim Slattery

Agent86 said:
One More question:

<c:eek:ut value="${myForm.intDummy + 5}" /> works fine with an integer
property.

What if I want to transform a String ?

<c:eek:ut value="${myForm.strDummy + "__"}" /> does not work.

How should I do that ?

Try single quotes inside the expression. The nested double-quotes are
going to confuse the parser:

<c:eek:ut value="${myForm.strDummy + '__'}" />
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,022
Latest member
MaybelleMa

Latest Threads

Top