Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Struts s:property tag not working

 
Shobb Bob
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 349
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic