You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Tommy Becker <to...@motricity.com> on 2008/02/12 16:31:09 UTC

Get current URL on a page

Is there a way to get the URL for the current page using struts tags?  I 
thought I had access to the HttpRequest, and therefore could just use 
getRequestURL() but it appears the docs have led me astray :/
<http://www.motricity.com>


NOTICE: This e-mail message is for the sole use of the intended recipient(s) and may contain confidential and privileged information of Motricity.  Any unauthorized review, use, disclosure or distribution is prohibited.  If you are not the intended recipient, please contact the sender by reply e-mail and destroy all copies of the original message.

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Get current URL on a page

Posted by Randy Burgess <RB...@nuvox.com>.
I'm not sure how to get it with OGNL but you could make your action
implement ServletRequestAware, call request.getRequestURL() somewhere in
your action and set that value in an instance variable with a getter and
then call the getter in  your action.

Regards,
Randy Burgess
Sr. Web Applications Developer
Nuvox Communications



> From: Tommy Becker <to...@motricity.com>
> Reply-To: Struts Users Mailing List <us...@struts.apache.org>
> Date: Tue, 12 Feb 2008 10:52:07 -0500
> To: Struts Users Mailing List <us...@struts.apache.org>
> Subject: Re: Get current URL on a page
> 
> Unfortunately it is.  I'm creating a url to another site using <s:url>
> and passing the current url as a parameter.  I suppose I don't *have* to
> use <s:url>  Is it not possible?
> /*
> 
> */ <http://www.motricity.com>
> 
> 
> Randy Burgess wrote:
>> If the value is not going into a struts tag then just use JSTL.
>> 
>> Regards,
>> Randy Burgess
>> Sr. Web Applications Developer
>> Nuvox Communications
>> 
>> 
>> 
>>   
>>> From: Tommy Becker <to...@motricity.com>
>>> Reply-To: Struts Users Mailing List <us...@struts.apache.org>
>>> Date: Tue, 12 Feb 2008 10:31:09 -0500
>>> To: Struts Users Mailing List <us...@struts.apache.org>
>>> Subject: Get current URL on a page
>>> 
>>> Is there a way to get the URL for the current page using struts tags?  I
>>> thought I had access to the HttpRequest, and therefore could just use
>>> getRequestURL() but it appears the docs have led me astray :/
>>> <http://www.motricity.com>
>>> 
>>> 
>>> NOTICE: This e-mail message is for the sole use of the intended recipient(s)
>>> and may contain confidential and privileged information of Motricity.  Any
>>> unauthorized review, use, disclosure or distribution is prohibited.  If you
>>> are not the intended recipient, please contact the sender by reply e-mail
>>> and
>>> destroy all copies of the original message.
>>> 
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>>> For additional commands, e-mail: user-help@struts.apache.org
>>> 
>>>     
>> 
>> 
>> 
>> This email and any attachments ("Message") may contain legally privileged
>> and/or confidential information.  If you are not the addressee, or if this
>> Message has been addressed to you in error, you are not authorized to read,
>> copy, or distribute it, and we ask that you please delete it (including all
>> copies) and notify the sender by return email.  Delivery of this Message to
>> any person other than the intended recipient(s) shall not be deemed a waiver
>> of confidentiality and/or a privilege.
>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>> 
>>   
> 
> NOTICE: This e-mail message is for the sole use of the intended recipient(s)
> and may contain confidential and privileged information of Motricity.  Any
> unauthorized review, use, disclosure or distribution is prohibited.  If you
> are not the intended recipient, please contact the sender by reply e-mail and
> destroy all copies of the original message.
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 



This email and any attachments ("Message") may contain legally privileged and/or confidential information.  If you are not the addressee, or if this Message has been addressed to you in error, you are not authorized to read, copy, or distribute it, and we ask that you please delete it (including all copies) and notify the sender by return email.  Delivery of this Message to any person other than the intended recipient(s) shall not be deemed a waiver of confidentiality and/or a privilege.

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Get current URL on a page

Posted by Dave Newton <ne...@yahoo.com>.
Don't recall off-hand; IIRC there's a request wrapper that has a getRequest()
method that I thought returned the underlying request, but I could be
off-target on that one.

Personally I still think exposing the request via the action is a better way
of doing it, if this is the way you're going to implement this functionality.

Dave

--- Tommy Becker <to...@motricity.com> wrote:

> Ugh.  Thanks for the info, but now there's another problem.   I'm using 
> Tiles 2, and apparently it's manipulating the request url.  When I do 
> this, I'm getting back the url to the Tiles template I'm using to render 
> the page, not the originally requested url  Any ideas on how to get 
> around that?
> 
> 
> Dave Newton wrote:
> > --- Tommy Becker <to...@motricity.com> wrote:
> >   
> >> Unfortunately it is.  I'm creating a url to another site using <s:url> 
> >> and passing the current url as a parameter.  I suppose I don't *have* to
> 
> >> use <s:url>  Is it not possible?
> >>     
> >
> > The S2 OGNL docs say there's access to the request *context*, which means
> the
> > request attributes.
> >
> > If you're doing this in the result of an S2 action one way would be to
> expose
> > the request in the action. If you're a glutton:
> >
> > <s:property
> >
>
value="#context.get('com.opensymphony.xwork2.dispatcher.HttpServletRequest').getRequestURL()"/>
> >
> > Dave
> >
> >   
> >> Randy Burgess wrote:
> >>     
> >>> If the value is not going into a struts tag then just use JSTL.
> >>>       
> >>>> From: Tommy Becker <to...@motricity.com>
> >>>>
> >>>> Is there a way to get the URL for the current page using struts tags? 
> I
> >>>> thought I had access to the HttpRequest, and therefore could just use
> >>>> getRequestURL() but it appears the docs have led me astray :/
> >>>> <http://www.motricity.com>
> >>>>
> >>>>         
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > For additional commands, e-mail: user-help@struts.apache.org
> >
> >   
> 
> NOTICE: This e-mail message is for the sole use of the intended
> recipient(s) and may contain confidential and privileged information of
> Motricity.  Any unauthorized review, use, disclosure or distribution is
> prohibited.  If you are not the intended recipient, please contact the
> sender by reply e-mail and destroy all copies of the original message.
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Get current URL on a page

Posted by Tommy Becker <to...@motricity.com>.
Ugh.  Thanks for the info, but now there's another problem.   I'm using 
Tiles 2, and apparently it's manipulating the request url.  When I do 
this, I'm getting back the url to the Tiles template I'm using to render 
the page, not the originally requested url  Any ideas on how to get 
around that?


Dave Newton wrote:
> --- Tommy Becker <to...@motricity.com> wrote:
>   
>> Unfortunately it is.  I'm creating a url to another site using <s:url> 
>> and passing the current url as a parameter.  I suppose I don't *have* to 
>> use <s:url>  Is it not possible?
>>     
>
> The S2 OGNL docs say there's access to the request *context*, which means the
> request attributes.
>
> If you're doing this in the result of an S2 action one way would be to expose
> the request in the action. If you're a glutton:
>
> <s:property
> value="#context.get('com.opensymphony.xwork2.dispatcher.HttpServletRequest').getRequestURL()"/>
>
> Dave
>
>   
>> Randy Burgess wrote:
>>     
>>> If the value is not going into a struts tag then just use JSTL.
>>>       
>>>> From: Tommy Becker <to...@motricity.com>
>>>>
>>>> Is there a way to get the URL for the current page using struts tags?  I
>>>> thought I had access to the HttpRequest, and therefore could just use
>>>> getRequestURL() but it appears the docs have led me astray :/
>>>> <http://www.motricity.com>
>>>>
>>>>         
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>   

NOTICE: This e-mail message is for the sole use of the intended recipient(s) and may contain confidential and privileged information of Motricity.  Any unauthorized review, use, disclosure or distribution is prohibited.  If you are not the intended recipient, please contact the sender by reply e-mail and destroy all copies of the original message.

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Get current URL on a page

Posted by Dave Newton <ne...@yahoo.com>.
--- Dave Newton <ne...@yahoo.com> wrote:
> <s:property
>
value="#context.get('com.opensymphony.xwork2.dispatcher.HttpServletRequest').getRequestURL()"/>

Too much cut, not enough paste:

<s:property
value="#context.get(@org.apache.struts2.StrutsStatics@HTTP_REQUEST).getRequestURL()"/>

Dave


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Get current URL on a page

Posted by Dave Newton <ne...@yahoo.com>.
--- Tommy Becker <to...@motricity.com> wrote:
> Unfortunately it is.  I'm creating a url to another site using <s:url> 
> and passing the current url as a parameter.  I suppose I don't *have* to 
> use <s:url>  Is it not possible?

The S2 OGNL docs say there's access to the request *context*, which means the
request attributes.

If you're doing this in the result of an S2 action one way would be to expose
the request in the action. If you're a glutton:

<s:property
value="#context.get('com.opensymphony.xwork2.dispatcher.HttpServletRequest').getRequestURL()"/>

Dave

> Randy Burgess wrote:
> > If the value is not going into a struts tag then just use JSTL.
> >> From: Tommy Becker <to...@motricity.com>
> >>
> >> Is there a way to get the URL for the current page using struts tags?  I
> >> thought I had access to the HttpRequest, and therefore could just use
> >> getRequestURL() but it appears the docs have led me astray :/
> >> <http://www.motricity.com>
> >>


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Get current URL on a page

Posted by Tommy Becker <to...@motricity.com>.
Unfortunately it is.  I'm creating a url to another site using <s:url> 
and passing the current url as a parameter.  I suppose I don't *have* to 
use <s:url>  Is it not possible?
/*

*/ <http://www.motricity.com>


Randy Burgess wrote:
> If the value is not going into a struts tag then just use JSTL.
>
> Regards,
> Randy Burgess
> Sr. Web Applications Developer
> Nuvox Communications
>
>
>
>   
>> From: Tommy Becker <to...@motricity.com>
>> Reply-To: Struts Users Mailing List <us...@struts.apache.org>
>> Date: Tue, 12 Feb 2008 10:31:09 -0500
>> To: Struts Users Mailing List <us...@struts.apache.org>
>> Subject: Get current URL on a page
>>
>> Is there a way to get the URL for the current page using struts tags?  I
>> thought I had access to the HttpRequest, and therefore could just use
>> getRequestURL() but it appears the docs have led me astray :/
>> <http://www.motricity.com>
>>
>>
>> NOTICE: This e-mail message is for the sole use of the intended recipient(s)
>> and may contain confidential and privileged information of Motricity.  Any
>> unauthorized review, use, disclosure or distribution is prohibited.  If you
>> are not the intended recipient, please contact the sender by reply e-mail and
>> destroy all copies of the original message.
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>>
>>     
>
>
>
> This email and any attachments ("Message") may contain legally privileged and/or confidential information.  If you are not the addressee, or if this Message has been addressed to you in error, you are not authorized to read, copy, or distribute it, and we ask that you please delete it (including all copies) and notify the sender by return email.  Delivery of this Message to any person other than the intended recipient(s) shall not be deemed a waiver of confidentiality and/or a privilege.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>   

NOTICE: This e-mail message is for the sole use of the intended recipient(s) and may contain confidential and privileged information of Motricity.  Any unauthorized review, use, disclosure or distribution is prohibited.  If you are not the intended recipient, please contact the sender by reply e-mail and destroy all copies of the original message.

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Get current URL on a page

Posted by Randy Burgess <RB...@nuvox.com>.
If the value is not going into a struts tag then just use JSTL.

Regards,
Randy Burgess
Sr. Web Applications Developer
Nuvox Communications



> From: Tommy Becker <to...@motricity.com>
> Reply-To: Struts Users Mailing List <us...@struts.apache.org>
> Date: Tue, 12 Feb 2008 10:31:09 -0500
> To: Struts Users Mailing List <us...@struts.apache.org>
> Subject: Get current URL on a page
> 
> Is there a way to get the URL for the current page using struts tags?  I
> thought I had access to the HttpRequest, and therefore could just use
> getRequestURL() but it appears the docs have led me astray :/
> <http://www.motricity.com>
> 
> 
> NOTICE: This e-mail message is for the sole use of the intended recipient(s)
> and may contain confidential and privileged information of Motricity.  Any
> unauthorized review, use, disclosure or distribution is prohibited.  If you
> are not the intended recipient, please contact the sender by reply e-mail and
> destroy all copies of the original message.
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
> 



This email and any attachments ("Message") may contain legally privileged and/or confidential information.  If you are not the addressee, or if this Message has been addressed to you in error, you are not authorized to read, copy, or distribute it, and we ask that you please delete it (including all copies) and notify the sender by return email.  Delivery of this Message to any person other than the intended recipient(s) shall not be deemed a waiver of confidentiality and/or a privilege.

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org