|
-
March 6th, 2012, 04:21 AM
#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..
-
March 6th, 2012, 12:32 PM
#2
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.
-
March 9th, 2012, 01:54 AM
#3
Re: How to redirect to login page if not logged in
I know in .net how would this happen but dnt know in java.
-
March 10th, 2012, 06:59 AM
#4
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|