We are using Struts 2 Dispatcher Result to forward our request to some jsp page.
In struts.xml
Now we are able to see success.jsp but the request attributes we set are becoming null in success.jsp
We used dispatcher because we need the same request to be forwarded so that the request attributes we set can be retrieved in success.jsp But it is not happening and we are getting nulls instead.
Besides that this isn't the canonical way to send data to a JSP in Struts 2...
Are you saying that you're calling request.setAttribute(...) in the method that then returns "success"? I don't see how that could fail to work.
By the way, "dispatcher" is the default result type, and the default param is "location"--your other result declarations are functionally equivalent to the "success" result you define by hand.
I am calling request.setAttribute(...) in the method that returns success . i.e in execute method before returning success. I am not understanding why it is failing to set request attributes.
If you're doing this correctly, calling the action you think you are, and showing the result you think you are, there's no way this can fail. While I don't do it often (Struts 2 has a better way to pass data to a JSP, as I've already stated), it's unlikely to be an S2 issue.
It'd be so much easier if you just included all the relevant code and configuration at once.
>How are you obtaining the request?
I was wondering the same thing. Probably Vivek tried Struts 1.X where it is available as part of the formal parameters of execute method
There should be a way to access request object anyway, IMHO, I know Struts 2 propose setting/passing values via properties, but to be able to set request in attribute is so much easier.