You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Sumanth <ro...@gmail.com> on 2015/02/03 19:11:31 UTC

How to know "Redirected From URL"

Hello Guys,

 I have a page which has a back button. I need to set the "URL" for this
back button dynamically depending on which page directed the user to this
page.

Is there any way of knowing from Which URL was i Redirected from in
Tapestry?


Thanks in advance

Re: How to know "Redirected From URL"

Posted by Geoff Callender <ge...@gmail.com>.
Here's an example that suits simple situations:

	T5.4: http://jumpstart.doublenegative.com.au/jumpstart7/examples/navigation/returntopage1/abc
	T5.3: http://jumpstart.doublenegative.com.au/jumpstart/examples/navigation/returntopage1/abc

Geoff

On 5 Feb 2015, at 12:38 pm, Bob Harner <bo...@gmail.com> wrote:

> Sumanth,
> 
> I don't think there is any out-of-the-box solution.
> 
> The Referer header is ultimately unreliable unless your users and their
> browsers are under your control. Relying on it for a return URL may also
> introduce a XSS vulnerability if you aren't careful.
> 
> I think you'll probably have to pass some identifier of the return-to page
> in the request. For example, each of the requesting pages could @Inject the
> page with the button on it, set some @Persist'd property of the injected
> page, then redirect to that injected page. That injected page (the page
> with the button on it) would then be able to check that property to know
> which page requested it. You could also do fancier things with a
> session-based map (maybe a ConcurrentHashMap) that stores the return-to
> page associated with each request, assigning a unique value (e.g. UUID) to
> use as a page ID value that would also serve as the key to the map. That
> would especially be needed if your app needs to function properly across
> multiple browser tabs.
> On Feb 3, 2015 1:25 PM, "Thiago H de Paula Figueiredo" <th...@gmail.com>
> wrote:
> 
>> On Tue, 03 Feb 2015 16:11:31 -0200, Sumanth <ro...@gmail.com>
>> wrote:
>> 
>> Hello Guys,
>>> 
>>> I have a page which has a back button. I need to set the "URL" for this
>>> back button dynamically depending on which page directed the user to this
>>> page.
>>> 
>>> Is there any way of knowing from Which URL was i Redirected from in
>>> Tapestry?
>>> 
>> 
>> Have you tried getting the "Referer" HTTP header from Request?
>> 
>> @Inject
>> private Request request;
>> 
>> String url = request.getHeader("Referer");
>> 
>> --
>> Thiago H. de Paula Figueiredo
>> Tapestry, Java and Hibernate consultant and developer
>> http://machina.com.br
>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> For additional commands, e-mail: users-help@tapestry.apache.org
>> 
>> 


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: How to know "Redirected From URL"

Posted by Bob Harner <bo...@gmail.com>.
Sumanth,

I don't think there is any out-of-the-box solution.

The Referer header is ultimately unreliable unless your users and their
browsers are under your control. Relying on it for a return URL may also
introduce a XSS vulnerability if you aren't careful.

I think you'll probably have to pass some identifier of the return-to page
in the request. For example, each of the requesting pages could @Inject the
page with the button on it, set some @Persist'd property of the injected
page, then redirect to that injected page. That injected page (the page
with the button on it) would then be able to check that property to know
which page requested it. You could also do fancier things with a
session-based map (maybe a ConcurrentHashMap) that stores the return-to
page associated with each request, assigning a unique value (e.g. UUID) to
use as a page ID value that would also serve as the key to the map. That
would especially be needed if your app needs to function properly across
multiple browser tabs.
 On Feb 3, 2015 1:25 PM, "Thiago H de Paula Figueiredo" <th...@gmail.com>
wrote:

> On Tue, 03 Feb 2015 16:11:31 -0200, Sumanth <ro...@gmail.com>
> wrote:
>
>  Hello Guys,
>>
>>  I have a page which has a back button. I need to set the "URL" for this
>> back button dynamically depending on which page directed the user to this
>> page.
>>
>> Is there any way of knowing from Which URL was i Redirected from in
>> Tapestry?
>>
>
> Have you tried getting the "Referer" HTTP header from Request?
>
> @Inject
> private Request request;
>
> String url = request.getHeader("Referer");
>
> --
> Thiago H. de Paula Figueiredo
> Tapestry, Java and Hibernate consultant and developer
> http://machina.com.br
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>

Re: How to know "Redirected From URL"

Posted by Thiago H de Paula Figueiredo <th...@gmail.com>.
On Tue, 03 Feb 2015 16:11:31 -0200, Sumanth <ro...@gmail.com>  
wrote:

> Hello Guys,
>
>  I have a page which has a back button. I need to set the "URL" for this
> back button dynamically depending on which page directed the user to this
> page.
>
> Is there any way of knowing from Which URL was i Redirected from in
> Tapestry?

Have you tried getting the "Referer" HTTP header from Request?

@Inject
private Request request;

String url = request.getHeader("Referer");

-- 
Thiago H. de Paula Figueiredo
Tapestry, Java and Hibernate consultant and developer
http://machina.com.br

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org