CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Mar 2012
    Posts
    1

    How to redirect to login page if not logged in

    hi,

    i have a tomcat web application and it is working properly. i have only javascript and jsp but if user types any url of any jsp without login its displaying that page for that i written the code like this in jsp.... but its not working........ so any one please help me...........

    the code is

    <% if(null == session.getAttribute("username")){
    response.sendRedirect("./jsp/logout.jsp");
    }else { %>
    <a href="../jsp/useradmin.jsp?">Add User </a> <%} %>

    this is not redirecting to login page if i entered url useradmin page directly without login. any one please tell me sollution..

  2. #2
    Join Date
    May 2006
    Location
    UK
    Posts
    4,473

    Re: How to redirect to login page if not logged in

    Have you tried printing the value returned by session.getAttribute("username") to the screen to see what it is returning.
    Posting code? Use code tags like this: [code]...Your code here...[/code]
    Click here for examples of Java Code

  3. #3
    Join Date
    Mar 2012
    Posts
    2

    Re: How to redirect to login page if not logged in

    I know in .net how would this happen but dnt know in java.

  4. #4
    Join Date
    Jan 2011
    Posts
    24

    Re: How to redirect to login page if not logged in

    have you tried spring security ? it has such feature out of box.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured