I have the following action in my struts.xml file:
<result name="success">test/success.jsp</result>
<result name="blocked" type="redirect">
<param name="location">test/blocked.jsp</param>
<param name="paramkey">${paramvalue}</param>
</result>
The first result works fine. The second result can only be triggered when an interceptor blocks the flow of the request and instead of invoking the action class it returns the result "blocked". So far so good. However, I'm having trouble with getting the ${paramvalue} ognl expression evaluated. The value of paramValue is NOT defined in my action class (by using a getParamvalue() method). Instead, I want the interceptor class to push this value on the valuestack so that it gets correctly filled in. I used the following snippet in my interceptor class but the expression ${paramvalue} stays empty:
ValueStack stack = ActionContext.getContext().getValueStack();
stack.push("paramkey");
stack.set("paramkey", "some_random_test_value");
How can I make the expression ${paramvalue}
work as intended from within an interceptor class?
You should better push the value, because OGNL searches from top down the stack and if it found occurrence of the key it return a value.