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

Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Frameworks » Struts
Bookmark "Struts s:property tag not working" Watch "Struts s:property tag not working" New topic

Struts s:property tag not working

Shobb Bob

Joined: Dec 18, 2008
Posts: 4
Hi Guys

I have a action class which gets data from a form, see code below:

If the form input is successful it will forward to my success.jsp page. The problem is I am trying to use <s roperty value="name"> to get the value of the variable name in the action class, but when I run the code it returns as empty. Does anyone know where I am going wrong?

[ December 18, 2008: Message edited by: Shobb Bob ]
[ December 18, 2008: Message edited by: Shobb Bob ]
Tom Rispoli
Ranch Hand

Joined: Aug 29, 2008
Posts: 349
The code looks right, are you sure that the "name" property in your action class is getting set to something? The s roperty tag may display nothing because "name" is never set to anything.
Shobb Bob

Joined: Dec 18, 2008
Posts: 4
Well, here is my struts.xml file:

If I change "<result type="redirect-action">FaultReport</result>" with "<result>/main/site/page.jsp</result>" it will work. But I would prefer to use the first method since then I can specify a custom name for the URL.
David Newton

Joined: Sep 29, 2008
Posts: 12617

If you use redirectAction it redirects--so the current action is lost and a new one is instantiated, meaning that the current value of the "name" property will be lost.
I agree. Here's the link:
subject: Struts s:property tag not working
Similar Threads
The right way to do a action/form in Struts 2?
Struts2 annotation validation
Form Data not being populated in Struts 2
Adding more than one validation to form field
Struts 2: conditional validation, how to do that?