title: How to get the request URL in Struts 2?
body: <p>I'm trying to redirect to the page where the user tried to login.</p>
  
  <p>I mean, somepage → login → somepage</p>
  
  <p>I know this;</p>
  
  <p>In LoginAction</p>
  
  <pre><code>HttpServletRequest request = ServletActionContext.getRequest();
  String url = request.getServletPath();
  setUrl(url);
  </code></pre>
  
  <p>In struts.xml</p>
  
  <pre><code> &lt;action name="LoginPro" method="login" class="LoginAction"&gt;
      &lt;result type="redirect"&gt;${url}&lt;/result&gt;
      &lt;result name="input" type="tiles"&gt;login.error&lt;/result&gt;
   &lt;/action&gt;
  </code></pre>
  
  <p>But it's not working.
  The requested url is always "LoginPro" which is handling login process.
  When a user clicks login button, page goes to LoginPro. So the request url is always loginPro...</p>
  
  <p>It seems to be this way;
  somepage → login → loginPro → LoginAction(request url is loginPro..) → loginPro </p>
  
  <p>How can I redirect users to the page where they tried to login?</p>