0

I am migrating a project from Struts 1 to Struts 2.

The requirement is to validate if the result jsp is secured or open. If secured, we have to take the customer to an error jsp which states that the page is secured.

This was implemented in struts 1 by overriding the processForwardConfig of the RequestProcessor and findForwardConfig("noPageAccessError")to the error jsp if page is secured.

(Note: There is a global <forward name="noPageAccessError" redirect="false" path="/noPageAccessError.jsp"/> in the struts.xml for this error jsp)

I am trying to implement this in the struts 2, by using a customInterceptor that implements the beforeResult of the PreResultListener. I got the results location/jsp details (hat tip to Roman C Understanding Struts2 Internals : Result Configuration), and was able to find my permissions levels, but I am not able to re-direct to the error page if the page is secured.

How can I change the resultCode to a the error.jsp?

  • 1
    By calling `invocation.setResultCode`? It’s not clear what specific difficulty you’re having. – Dave Newton May 23 '22 at 13:06
  • 1
    @DaveNewton Is it possible to add a facepalm emoji here in the comments? If yes, I can add quite a few. I had done all that was needed for the verification and missed a simple, obvious last step in setting the result code by thinking too much. Thanks for pointing it out. – Krishnaraj V May 23 '22 at 13:38
  • 1
    ‍♂️ I’ll probably add something to the wiki; I didn’t see a good example on a cursory search. `PreResultListener` has never been explained well, IMO. – Dave Newton May 23 '22 at 13:43

0 Answers0