See my other post in this thread why it's a Really Bad Idea to store the
previous URL in the session.  I promise you, you're only gonna cause
yourself more pain.

chris

> -----Original Message-----
> From: John Sherlock [mailto:[EMAIL PROTECTED]]
> Sent: Friday, September 20, 2002 4:09 AM
> To: 'Struts Users Mailing List'
> Subject: RE: Backtracking & Breadcrumbs
> 
> 
> >I was kind of hoping for something at a "higher level", 
> >that once set up would just work. I guess I could override 
> >the Action class, but I'm not sure how to go about doing 
> >it that way.
> 
> Howard,
> 
> Here's a bit of a dirty hack... if you extend the Action 
> class you could
> possibly add the functionality to find out what page you have 
> just come from
> and set the name of that page in the session. That way the 
> next page could
> just recall the name of the previous page from the session. 
> Because it is
> done in the Action class it will always be done so you don't 
> have to worry
> about it.
> 
> In your custom Action class you can use 
> 
> String strReferringPage = request.getHeader("Referer"); 
> 
> to get the URL of the page you have just come from. Then you 
> can set the
> referring page in the session using 
> 
> session.setAttribute("previousPage", strReferringPage);
> 
> - not sure if 'request.getHeader("Referer")' will always 
> achieve the desired
> effect. If doesn't work you could have a hidden field on each 
> form called
> 'referringPage' with the value being the name of that page. 
> You could pull
> this value out of the request in the Action class and set it 
> in the session
> in the same way as above. The drawback with this approach is 
> that you have
> to remember to put the hidden field on each page and in the 
> case of pages
> with no form and just a link, you will have to append
> ?referringPage=[nameOfPage] to all your hrefs. You could 
> possibly eliminate
> the need to do this yourself by writing a custom link tag and form tag
> (extending the tags in the html-tags lib) that will do it for 
> you but that
> could be more trouble than it's worth.
> 
> Extending the Action class is quite simple - a good 
> explanation on how to do
> it can be found in chapter 5 (page 3) of Chuck Cavaness' book 
> on Struts.
> http://www.theserverside.com/resources/strutsreview.jsp .
> 
> Regards,
> 
> Jonny :)
> 
> 
> John Sherlock
> 
> Software Engineer 
> Macalla Software Ltd
> 
> --
> To unsubscribe, e-mail:   
> <mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail: 
> <mailto:[EMAIL PROTECTED]>
> 

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to