Note that there are some explanatory texts on larger screens.

plurals
  1. POSpring Security 3.0 Redirect to page that timed out
    primarykey
    data
    text
    <p>I am using Spring Security 3.0.6 and I would like to be able to do the following: </p> <p>If the user is a on a page and a session timeout occurs, the user will be taken to the log in page and on valid log in redirected back to the page the timeout occurred on.</p> <p>I currently have the following in my security.xml file.</p> <pre><code>&lt;http auto-config="true" use-expressions="true"&gt; &lt;form-login login-page="/login" default-target-url="/main" always-use-default-target="false" authentication-failure-url="/login.html?error=true" authentication-success-handler-ref="authenticationSuccessHandler" /&gt; &lt;remember-me/&gt; &lt;logout logout-success-url="/login" /&gt; &lt;/http&gt; </code></pre> <p>This is my authentication class:</p> <pre><code>public class AuthenticationSuccessHandler extends SavedRequestAwareAuthenticationSuccessHandler { public void onAuthenticationSuccess(HttpServletRequest request, HttpServletResponse response, Authentication authentication) throws IOException { String url = ""; HttpSession session = request.getSession(false); if (session != null) { SavedRequest savedRequest = (SavedRequest) session.getAttribute(WebAttributes.SAVED_REQUEST); if (savedRequest != null) { url = savedRequest.getRedirectUrl(); } } System.out.println("url: "+ url); if (url == "") { response.sendRedirect(request.getContextPath()+"/main"); } else { response.sendRedirect(url); } } </code></pre> <p>}</p> <p>I send the user back to the log in page via javascript like:</p> <pre><code>window.location.href="/login"; </code></pre> <p>The url is always null in my authentication class. How can I make this work so Spring will redirect to the correct page?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload