Search code examples
struts2struts-config

Add a variable to my struts config result redirection


I have a page where I'm "Viewing session info" (where session in this context is a business element. Think of a session like a training session). Part of this session info is a list of files. (An example of a session file would be the sign-in sheet of all the people who attended the session.) Clicking the link at the end of the list of files will delete the file from the session via a method called `inativeateSe

In my struts config for inactivateSessionMaterial, I have the following result

<result name="success">
    /secure/courses/sessions/view_session_info.jsp
</result>

But this is insufficient. It really needs to be view_session_info.jsp?sessionId=1234. How can I add that variable (session id) to the end of this? Something like

<result name="success">
    /secure/courses/sessions/view_session_info.jsp?sessionId=$sessionId
</result>

Solution

  • Just use <param> tag inside your action for all results in this action

    <action>
       <param name="sessionId">${sessionId}</param>
       <result>...</result>
    </action>
    

    or for specific action result.

    <action>
       <result>
          <param name="location">...</param>
          <param name="sessionId">${sessionId}</param>
       </result>
    </action>