This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
The moose likes Struts and the fly likes Get FormBean's property in JSP page. Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Frameworks » Struts
Reply Bookmark "Get FormBean Watch "Get FormBean New topic
Author

Get FormBean's property in JSP page.

SoonAnn Lim
Ranch Hand

Joined: Jun 21, 2001
Posts: 155
Hi,
I am using Struts 1.1 in this topic. I have a very simple page with only 1 input field for age. I assign it to DynaActionForm with request scope. Then I create a simple Action class that does nothing but forwarding to the landing page, which is a jsp page. At landing page, I want to display different messages based on the age field in Formbean. At landing page, I am trying to get the value of age field from the FormBean and assign it to a java variable so I can perform logic in jsp page, meaning using <% %> scriplet. Here is the pseudocode of landing page
########################################
<% Get Age field and assign to java variable.
If (Age < 10) {
%>
Hello Kid
<% }else if (Age between 10 - 20){
%>
Hello Dude
<% }else{
%>
Hello Folks
<% } %>
##########################################
Can someone give me some clue?
Thanks

########################################
sandy gupta
Ranch Hand

Joined: Jan 30, 2001
Posts: 228
make the action scope session
S


Adios
sandy gupta
Ranch Hand

Joined: Jan 30, 2001
Posts: 228
and yeah you should use the struts bean tag to get the property value of the bean members.
<bean:write property="age"/>
will print the age value on the page for you.
OR
You could get the form from the scope that u set it in session/request using the name attribute that u specify in the struts config and then call the getters and setters. The solution above is cleaner.
S
SoonAnn Lim
Ranch Hand

Joined: Jun 21, 2001
Posts: 155
I am not very clear about this.
<bean:write property="age" /> will output to the page. How can I assign this value in jsp scriptlet?
<% int age = <bean:write property="age"/> ; %>
Something like that?

Thanks
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Get FormBean's property in JSP page.
 
Similar Threads
How html:errors Functionality works
Struts2 very simple validation doesn't work
How to make dynamic radio button checked
bean:message in bean:define tag
problem with config implicit variable