Announcement Announcement Module
No announcement yet.
How to redirect after login Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to redirect after login

    Hello folks,
    I am using Spring Security 3.1.3.
    I created a login page myself; when the user logs in successfully he is redirected to the "/". No prob till here..
    the Login url is

    and after login it is

    Now when i again enter the login url "localhost:8080/org/login" in a different tab of the same browser or put the login url in the address bar and hit enter, i again get the same login page; rather it should redirect to the already logged in page !

    So how can i do this. Please help.

  • #2
    Technically, you are not supposed to put the login page' URL in the address bar.
    The idea is that you try to get to a URL which is a 'protected resource', and then Spring redirects you to the login URL (you do not get there by your own), and then redirects you back to the 'protected resource' (after the successful login).


    • #3
      ok.. yeah true.. but what if a user knows and puts in the URL and hits enter he must be redirected to the protected resource. he shud not be taken to the login page again..


      • #4
        paste here your xml, etc, so it will be easier to help.
        In addition, have a look here.


        • #5
          You need some logic in your login page to determine if the user is already authenticated and if so redirect them to another page. For example, if the HttpServletRequest.getRemoteUser() is not null you could redirect the user to a default page.