I need a help in understanding how to solve the below issues.
Consider in a web based application, I am using the doGet Method. My application contains a Login page, Home Page, Profile page.
As it is a get method i can see the parameters in the URL.
So my query is 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?? If so in how many ways we can achieve this??
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.
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.
posted 8 years ago
Thank you very much for all you people response.
But, could some one clearly explain me how can i do this using web.xml