Chinna Ravindra wrote:if I am not logged in and if I give the url of my profile page directly it should take me to the Login page, instead of showing the profile page.
How can we achieve this??
In common, when user comes through the login page, we will be keeping a
session variable with the value of 'Username' that user entered.
So in the urls/resources (
jsp, servlets) we can check for existence of this variable. If the session variable (which is stored in session scope when user inputs the username, password) value is null (can be extended) then we can redirect the user to login page.
Note:
Even though we do the same in servlet and, if the jsp's are kept outside the WEB-INF then they can be accessed directly by hitting the relevant urls. So in this case we need to do the same in jsp's also. Or we can keep it inside the WEB-INF directory.