File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes How to store the page context and where would it be better. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Servlets
Bookmark "How to store the page context and where would it be better. " Watch "How to store the page context and where would it be better. " New topic
Author

How to store the page context and where would it be better.

Alex Iordache
Ranch Hand

Joined: Mar 13, 2001
Posts: 62
In my site there would be a link to the third party site. After login to my site, the user clicks the
third party link on my site. The user will be directed to that site by opening new browser window. If
the user navigate the third party site (say he browsed page no.3), then the information has to be stored
some where so that, if he comes to my site on next day and if he clicks the third party link on my site,
it has to take him directly to the Page 3 of third party site (as he browsed up to this page on previous
session).
Both sites are secured and implemented with Java technologies and user state is maintained with HttpSession.

What would be the better approach to store this information. Would it be better to store in my site
or third party site. If so, how? I don�t have any restrictions to play with the third party site to
make changes. I can�t store this information in session as they may expire and both sites are running
in different servers.
Anil Vupputuri
Ranch Hand

Joined: Oct 31, 2000
Posts: 527
I think Session is the only solution to ur requirement since it can be carried over muliple servers.

SCJP 1.5, SCEA, ICED (287,484,486)
Peter den Haan
author
Ranch Hand

Joined: Apr 20, 2000
Posts: 3252
In the interest of reducing the coupling between the sites, your site should preferably not keep any information about state on the third party site.
Using sessions is out of the question, as your typical session won't be around the next day You will have to persist this information, either in a database or in a cookie.
One way of implementing this is to have the third party site maintain a per-user, persistent state indicating the last location visited. This is most easily done using a page include or even better a filter servlet (or better still a Servlet 2.3 filter). Once you have that, create a special location which reads the state and redirects the user there (say, http://www.3rdpartysite.com/LastLocation; if you use a database, this would be a servlet; if you use cookies, it could even be plain HTML with a bit of JavaScript). If there is no last known location, it would redirect to the main index page.
Then all you'd have to do in your site is link to http://www.3rdpartysite.com/LastLocation.
This keeps the coupling very loose - the only coupling is the existence of this special location which is supposed to take the user to the last visited location.
- Peter

[This message has been edited by Peter den Haan (edited April 24, 2001).]
Alex Iordache
Ranch Hand

Joined: Mar 13, 2001
Posts: 62
Thanks a lot for spending your precious time. Do you have any high level description regarding how to use Servlet 2.3 filter for my problem. Right now I am using page include and each and every page has to call database to update the user lastlocation.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to store the page context and where would it be better.