• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

restricting access to a jsp

 
Ranch Hand
Posts: 88
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I am just testing out writing a dynamic web project in eclipse.
I have a login.jsp page .. if the user is successfully logged in , he goes to success.jsp page.

How can i prevent the users from directly going to the success page by typing the url to success page..
For now, i have just hard coded the user name and password in a java class
 
Ranch Hand
Posts: 45
Firefox Browser Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Store some value in the session attribute when user enters using login pae. Check for that attribute on success page if that is not present redirect the user back to login page.
 
Marshal
Posts: 27214
87
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Smitesh Shinde wrote:Store some value in the session attribute when user enters using login pae. Check for that attribute on success page if that is not present redirect the user back to login page.



Quite right. And do that check in a servlet filter, so that you don't have to put the code for the attribute check into every single page in your system.
 
Ranch Hand
Posts: 327
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Rajiv Chelsea wrote:How can i prevent the users from directly going to the success page by typing the url to success page.



What web server are you using with Eclipse? Tomcat?

1. You could move your jsp files to a directory located in the WEB-INF directory of your webapp. Such as:


2. You could use a security-constraint in your web.xml and restrict access to the success.jsp using a url-pattern.

This is how Tomcat *secures* access to the Tomcat manager webapp, http://localhost:8080/manager/html

 
Ranch Hand
Posts: 2234
Eclipse IDE Firefox Browser Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Quite right. And do that check in a servlet filter, so that you don't have to put the code for the attribute check into every single page in your system.



Do we need to hardcode anything specific taht should be set inside JSPs
and checked in Filters for this ??
 
Rajiv Chelsea
Ranch Hand
Posts: 88
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Smitesh and Paul
can you please provide some sample code to show how to do it in filters..
How to store a value in session when user goes to login.jsp
and check for the value when user goes to success.jsp
So that user cant go directly to success.jsp
How to do it all in a Filter
 
Every plan is a little cooler if you have a blimp. And a tiny ad.
free, earth-friendly heat - a kickstarter for putting coin in your pocket while saving the earth
https://coderanch.com/t/751654/free-earth-friendly-heat-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic