• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

Redirecting to Login Page  RSS feed

 
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

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??

Thanks & Regards,
Ravi.
 
Ranch Hand
Posts: 672
4
Eclipse IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Interceptors is one way of doing it..
 
Bhairava Surya
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you explain that with some example.
 
Prasad Krishnegowda
Ranch Hand
Posts: 672
4
Eclipse IDE Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What framework are you using for MVC?
 
Bhairava Surya
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please its not related to any framework.. consider its normal MVC2
 
Rancher
Posts: 1337
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Configuring web.xml to use servlet security for Home and Profile pages is sufficient for this; no need to use interceptors, filters, or anything else.
 
Ranch Hand
Posts: 182
Chrome Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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.
 
Bhairava Surya
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you very much for all you people response.

But, could some one clearly explain me how can i do this using web.xml
 
Lester Burnham
Rancher
Posts: 1337
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There's a section on that in the FAQ: http://faq.javaranch.com/java/ServletsFaq#security
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!