This week's book giveaway is in the Java in General forum.
We're giving away four copies of Think Java: How to Think Like a Computer Scientist and have Allen B. Downey & Chris Mayfield on-line!
See this thread for details.
Win a copy of Think Java: How to Think Like a Computer Scientist this week in the Java in General forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Added Functionality to Servlet...

 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a servlet, which takes me through few pages, among which the 1st page is security page which is also a servlet,only if valid then takes to the nextpage, say if i bookmark a particular page in the 1st servlet, the next time i open the bookmarked page, it should only take me to the security page ie security servlet and then get back to the bookmarked page. So in order to have this functionality what is the good approach to implement this. I think Hidden Form field or cookie might work.
Could anyone please help me out with this!
Thanks,
 
John Bateman
Ranch Hand
Posts: 320
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi
You could use a hidden form field, but it can be seen through a "view source" in the browser. You can also use a cookie but that would then allow someone else sitting down at the same computer (that a previous user already accessed the site with) access to your protected pages.
My suggestion, use a HttpSession and store a bean/object into it. This way you can store user preferences into the session, one of them being an 'authenticated' boolean. If the boolean is set to true, allow them to see the page you want, if it's false (not loggged in, or bad login) redirect them to the main page.
Hope this helps.

[This message has been edited by John Bateman (edited April 25, 2000).]
 
Anonymous
Ranch Hand
Posts: 18944
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks John Bateman.
As per your statement
You can also use a cookie but that would then allow someone else sitting down at the same computer (that a previous user already accessed the site with) access to your protected pages.
I will be taking care of the security, in order to get to the bookmarked page, the user first has to enter the valid id's before getting into the bookmarked page. Then it would'nt be a problem right. So i am not sure how to use cookies in this case.
I have 2 servlets, one is the searchServlet and the other is the
SecurityServlet, i have to get the info of the bookmarked URL in the searchservlet and how do i pass it on to the other servlet using cookies.
Any further suggestions!
Thanks,
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic