I’ve below entries in struts.xml
<action name="download" method="download" class="com.pqr.myaction">
<result name="error" type="redirectAction">callme</result>
</action>
<action name="callme" class="com.pqr.myaction">
<result name="imhere" type="tiles">imhere.tiles</result>
</action>
imhere.tiles corresponds to imhere.jsp in tiles & shows “download” link.
When I click download, I’m constructing the URL to donwload the package from & if that is null, I’m returning error & also setting class variable this.errMsg = “ERROR” & then displaying it in imhere.jsp
as shown below:
<s:if test="errMsg != null">
<div id="normalErrMsg"><p><s:property value="errMsg" escape="false" /></p></div>
</s:if>
<a href="/download">
<s:property value="getText('DOWNLOAD')" escape="false" />
</a>
But somehow, the control does not go to the above if condition at all.
Can any one tell me what is worng this behaviour?
Thanks!
A
redirectActionis just that, a redirect. Request attributes and parameters are lost, because it’s a new request, new action instance, etc.You can either forward, maintaining the URL in the address bar and staying in the same action, use the
"scope"interceptor to temporarily store messages/data, or store the messages in the session yourself and remove them on enteringmyaction.In this case I’m not sure I’d bother redirecting, though.