0

I have an action which (depending on the result) redirects to a suitable file:

<!-- /web/addaccount -->
<action name="addaccount" class="com.x.y.z.WebCreateAccountAction">      
  <result name="INVALIDLOGIN">/delete/confirm.jsp?err=SIGNIN</result>
  <result name="ERROR">/delete/error.html</result>
</action>

For some reason, when redirecting to delete/confirm.jsp, the parameter erris not passed in. I'm at a loss to why this is happening. Is this an incorrect way of passing params to JSP via Struts?

Roman C
  • 49,761
  • 33
  • 66
  • 176
Siddhartha
  • 4,296
  • 6
  • 44
  • 65

1 Answers1

0

Was just missing a:

type="redirect"

<result name="INVALIDLOGIN" type="redirect">/delete/confirm.jsp?err=SIGNIN</result>

Note: This is advised against, it would redirect directly to a JSP, which would be considered an S2 anti-pattern. See comments below.

Siddhartha
  • 4,296
  • 6
  • 44
  • 65
  • This would mean you're redirecting directly to a JSP, which would be considered an S2 anti-pattern. – Dave Newton Sep 14 '16 at 13:53
  • Ah interesting. @DaveNewton http://www.tutorialspoint.com/struts_2/struts_redirect_action.htm suggests using a redirect to JSP directly. Is that outdated now? – Siddhartha Sep 14 '16 at 19:13
  • @Siddhartha It has *never* been a good practice to mix direct JSPs with an action-oriented framework; all requests should go through an action. This applies across technologies (e.g., Struts 1 apps shouldn't use direct JSP access either). The only possible exceptions might be for landing pages, which would redirect to an action, or maybe login pages that interact with something at a lower level. It's not a rule that's enforceable by the framework--it's just convention. – Dave Newton Sep 14 '16 at 21:01
  • @Siddhartha That tutorial is likely fairly old, as S2 itself no longer advocates a particular Ajax methodology, other than deprecating its own (old) Dojo-based plugin, and having a relatively well-maintained jQuery plugin that isn't part of the official S2 project. – Dave Newton Sep 14 '16 at 21:02
  • @DaveNewton Thanks for the advice. Modified the answer to avoid misleading any who come by. – Siddhartha Sep 14 '16 at 21:26