This week's book giveaway is in the Mac OS forum.
We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line!
See this thread for details.
The moose likes Servlets and the fly likes Added Functionality to Servlet... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Servlets
Bookmark "Added Functionality to Servlet..." Watch "Added Functionality to Servlet..." New topic
Author

Added Functionality to Servlet...

Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
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

Joined: Mar 09, 2000
Posts: 320
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).]


SOURCE CODE should be SURROUNDED by "code" tags.
Anonymous
Ranch Hand

Joined: Nov 22, 2008
Posts: 18944
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,
 
GeeCON Prague 2014
 
subject: Added Functionality to Servlet...