title: Struts 2 - redirect page and display a different URL
body: <p>I'm using Struts 2 for my web app and working the authentication part. I am wondering when redirecting the page (action), how do I change the displayed URL it redirects to instead of from?</p>
  
  <p>For example, I have a login.action page that will submit to authentication.action, and if the user name and password are correct, it will be redirected to securePage.action. </p>
  
  <p>I do know how to do the redirect part (I tried both chain and redirectAction result type). What I want is that when the page gets redirected to the secure page, the URL will show ..../securePage.action. Right now, it remains authentication.action with a session ID.</p>
  
  <p>I'm sharing part of my struts.xml below</p>
  
  <p>
      
              
              
                   
                  
              
      </p>
  
  <pre><code> &lt;action name="login"&gt;
      &lt;result&gt;index.jsp&lt;/result&gt;
   &lt;/action&gt;
   &lt;action name="authentication" class="com.myapp.action.AuthenticationAction"&gt;
      &lt;result name="success" type="chain"&gt;hello&lt;/result&gt;
      &lt;result name="failure"&gt;index.jsp&lt;/result&gt;
   &lt;/action&gt;
    &lt;action name="hello" 
          class="com.myapp.action.HelloWorldAction" 
          method="execute"&gt;
          &lt;interceptor-ref name="myDefault"/&gt;
          &lt;result name="success"&gt;/HelloWorld.jsp&lt;/result&gt;
          &lt;result name="failure"&gt;index.jsp&lt;/result&gt;
    &lt;/action&gt;
  </code></pre>
  
  <p></p>
  
  <p>login.action will just open the index.jsp, which is the login that will submit to authentication</p>
  
  <p>authentication's action class simply takes the user name and password from login and set the session value "authorized" if it passes or redirect if the user name and password do not match.</p>
  
  <p>authentication will then redirect to hello (the secure page), using result type chain.</p>
  
  <p>action for hello uses my own authInterceptor that will check the session value - whether the current session is authorized. If not, go back to login. </p>