You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Oliver Lieven <ol...@provantis.de> on 2007/11/23 23:42:08 UTC

How to determine absolute URL of a mounted page?

Hi,

is there a way to determine the complete, absolute URL to a mounted page
(including protocol, host, port, application, filter and destination page)?
I need this to be able to send a link to a Registration-Confirmation page to
a user via email. 

I searched the forum already, but didn't find a working solution. All I
found were messages saying that since Wicket 1.3 all URLs are relative.
Reading the JavaDoc I also found various urlFor() and getRelativePath...()
methods, all returning relative paths.

What I would need is a method with a signature similar to

    url = getAbsolutePath(Request request, Class pageClass, PageParameters
parameters)

which returns an url like 
"http://localhost:8080/myapp/app/<page-alias>?...<params>...

Thanks for any hints on this,
Oliver

-- 
View this message in context: http://www.nabble.com/How-to-determine-absolute-URL-of-a-mounted-page--tf4864119.html#a13919803
Sent from the Wicket - User mailing list archive at Nabble.com.


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


Re: How to determine absolute URL of a mounted page?

Posted by John Patterson <jd...@gmail.com>.
On 25 Nov 2007, at 15:26, Johan Compagner wrote:

> also the port?
>

Yes the port is also contained in the host header so it works fine -  
as if the proxy was not there at all.  I know that Jetty always  
respects the host header.

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


Re: How to determine absolute URL of a mounted page?

Posted by Johan Compagner <jc...@gmail.com>.
also the port?




On Nov 25, 2007 8:47 PM, John Patterson <jd...@gmail.com> wrote:

>
> On 25 Nov 2007, at 13:01, Johan Compagner wrote:
>
> > If you virtual host in apache on a server (local ip 10.0.0.1)
> > it will rewrite the url and give it to tomcat
> > Then the request url is really
> > http://10.0.0.2:8080/myapp1context/XXXXXX
>
> I use Apache as a proxy and have got past this issue by using this
> directive:
>
>  ProxyPreserveHost On
>
> Stops the host name being rewritten so redirects etc still work
> correctly.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

Re: How to determine absolute URL of a mounted page?

Posted by John Patterson <jd...@gmail.com>.
On 25 Nov 2007, at 13:01, Johan Compagner wrote:

> If you virtual host in apache on a server (local ip 10.0.0.1)
> it will rewrite the url and give it to tomcat
> Then the request url is really
> http://10.0.0.2:8080/myapp1context/XXXXXX

I use Apache as a proxy and have got past this issue by using this  
directive:

  ProxyPreserveHost On

Stops the host name being rewritten so redirects etc still work  
correctly.

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


Re: How to determine absolute URL of a mounted page?

Posted by Johan Compagner <jc...@gmail.com>.
If you virtual host in apache on a server (local ip 10.0.0.1)

so

www.mydomain.com/

is virtual hosted by a tomcat server on a local network (10.0.0.2)

10.0.0.2:8080/myapp1context

and you do a request to apach
it will rewrite the url and give it to tomcat
Then the request url is really
http://10.0.0.2:8080/myapp1context/XXXXXX

this pdf also explains it a bit:
http://www.amitysolutions.com.au/documents/URLRewriting-technote.pdf

On Nov 25, 2007 7:32 PM, Jonathan Locke <jo...@gmail.com> wrote:

>
>
> sounds okay, but is it really necessary?  can you explain why?
> i always thought the browser would send the full request URL.
> in fact, i've had tomcat behind apache and this just works.
>
>
> Johan Compagner wrote:
> >
> > Can we then make something where we ask some setting first for the
> > host part? If not found we generate from the current request, which i
> > think for many many production environments will not  really work
> > because who doesnt virtualhost or puts apache in front of it?
> >
> > On 11/25/07, Al Maw <al...@gmail.com> wrote:
> >> Oliver Lieven wrote:
> >> > is there a way to determine the complete, absolute URL to a mounted
> >> page
> >> > (including protocol, host, port, application, filter and destination
> >> page)?
> >> > I need this to be able to send a link to a Registration-Confirmation
> >> page
> >> to
> >> > a user via email.
> >>
> >> Ah, yes, I've been meaning to get around to fixing that since forever,
> >> sorry. :-(
> >>
> >> See http://issues.apache.org/jira/browse/WICKET-609
> >>
> >> That's pretty apalling in terms of timescales. Apologies to all
> >> involved. Will have a look before RC2, promise. ;-)
> >>
> >> In the meantime, you can go:
> >> String url = "http://yourserver.com/" +
> >> RequestCycle.get().urlFor([...]).replaceAll("\\.\\./", "");
> >>
> >> Regards,
> >>
> >> Al
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> >> For additional commands, e-mail: users-help@wicket.apache.org
> >>
> >>
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> > For additional commands, e-mail: users-help@wicket.apache.org
> >
> >
> >
>
> --
> View this message in context:
> http://www.nabble.com/How-to-determine-absolute-URL-of-a-mounted-page--tf4864119.html#a13938331
> Sent from the Wicket - User mailing list archive at Nabble.com<http://nabble.com/>
> .
>
>
> ---------------------------------------------------------------------
>  To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

Re: How to determine absolute URL of a mounted page?

Posted by Jonathan Locke <jo...@gmail.com>.

sounds okay, but is it really necessary?  can you explain why?
i always thought the browser would send the full request URL.
in fact, i've had tomcat behind apache and this just works.


Johan Compagner wrote:
> 
> Can we then make something where we ask some setting first for the
> host part? If not found we generate from the current request, which i
> think for many many production environments will not  really work
> because who doesnt virtualhost or puts apache in front of it?
> 
> On 11/25/07, Al Maw <al...@gmail.com> wrote:
>> Oliver Lieven wrote:
>> > is there a way to determine the complete, absolute URL to a mounted
>> page
>> > (including protocol, host, port, application, filter and destination
>> page)?
>> > I need this to be able to send a link to a Registration-Confirmation
>> page
>> to
>> > a user via email.
>>
>> Ah, yes, I've been meaning to get around to fixing that since forever,
>> sorry. :-(
>>
>> See http://issues.apache.org/jira/browse/WICKET-609
>>
>> That's pretty apalling in terms of timescales. Apologies to all
>> involved. Will have a look before RC2, promise. ;-)
>>
>> In the meantime, you can go:
>> String url = "http://yourserver.com/" +
>> RequestCycle.get().urlFor([...]).replaceAll("\\.\\./", "");
>>
>> Regards,
>>
>> Al
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/How-to-determine-absolute-URL-of-a-mounted-page--tf4864119.html#a13938331
Sent from the Wicket - User mailing list archive at Nabble.com.


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


Re: How to determine absolute URL of a mounted page?

Posted by Johan Compagner <jc...@gmail.com>.
Can we then make something where we ask some setting first for the
host part? If not found we generate from the current request, which i
think for many many production environments will not  really work
because who doesnt virtualhost or puts apache in front of it?

On 11/25/07, Al Maw <al...@gmail.com> wrote:
> Oliver Lieven wrote:
> > is there a way to determine the complete, absolute URL to a mounted page
> > (including protocol, host, port, application, filter and destination
> page)?
> > I need this to be able to send a link to a Registration-Confirmation page
> to
> > a user via email.
>
> Ah, yes, I've been meaning to get around to fixing that since forever,
> sorry. :-(
>
> See http://issues.apache.org/jira/browse/WICKET-609
>
> That's pretty apalling in terms of timescales. Apologies to all
> involved. Will have a look before RC2, promise. ;-)
>
> In the meantime, you can go:
> String url = "http://yourserver.com/" +
> RequestCycle.get().urlFor([...]).replaceAll("\\.\\./", "");
>
> Regards,
>
> Al
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

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


Re: How to determine absolute URL of a mounted page?

Posted by Al Maw <al...@gmail.com>.
Oliver Lieven wrote:
> is there a way to determine the complete, absolute URL to a mounted page
> (including protocol, host, port, application, filter and destination page)?
> I need this to be able to send a link to a Registration-Confirmation page to
> a user via email. 

Ah, yes, I've been meaning to get around to fixing that since forever, 
sorry. :-(

See http://issues.apache.org/jira/browse/WICKET-609

That's pretty apalling in terms of timescales. Apologies to all 
involved. Will have a look before RC2, promise. ;-)

In the meantime, you can go:
String url = "http://yourserver.com/" + 
RequestCycle.get().urlFor([...]).replaceAll("\\.\\./", "");

Regards,

Al

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


Re: How to determine absolute URL of a mounted page?

Posted by Ryan Sonnek <ry...@gmail.com>.
> Personally I'd rather put it in a config file and know it's right rather
> than have it break if someone decides to virtual host/firewall/proxy the
> webapp and forgets to tweak the settings just right, (e.g., forgets the
> ProxyPreserveHost directive).

That's why you have automated tests to make sure that someone doesn't
break your configuration right?  =)

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


Re: How to determine absolute URL of a mounted page?

Posted by Sebastiaan van Erk <se...@sebster.com>.
Ryan Sonnek wrote:
> I'm trying to accomplish the same thing and think that wicket should
> provide such an API.  all of the "issues" mentioned are well known
> issues and other web frameworks still provide an API and just
> acknowledge the limitations.
> 
> This is pretty important for me as I can't necessarily "hardcode" the
> url when the application runs in several different environments
> (production vs development for example).  please vote for this JIRA
> issue and hopefully we can get some kind of API added.
> https://issues.apache.org/jira/browse/WICKET-609

I have production versus development as well; this does not preclude me 
from having different settings for each. There's a whole bunch of other 
settings which are prod/dev dependent anyhow, like database connection, 
admin email address (me on dev, the real application admin on prod), 
hibernate settings, etc... What's one more property?

Personally I'd rather put it in a config file and know it's right rather 
than have it break if someone decides to virtual host/firewall/proxy the 
webapp and forgets to tweak the settings just right, (e.g., forgets the 
ProxyPreserveHost directive).

Regards,
Sebastiaan

> 
> On Nov 23, 2007 7:03 PM, Oliver Lieven <ol...@provantis.de> wrote:
>> Hi Sebastiaan,
>>
>> thanks for your answer. Excellent point on potential problems when using
>> clusters, firewalls and proxies (I run into those already).
>>
>> I also thought on providing the URLs in a configuration file/spring config,
>> but "feared" there might be a simple and preferred "Wicket" way to determine
>> the URLs.
>>
>> Thanks alot,
>> Oliver
>>
>>
>>
>>
>>
>>
>>
>>
>> Sebastiaan van Erk wrote:
>>> What's wrong with putting this in a configuration file or just a
>>> constant. Because in general this does not really work.
>>>
>>> For example, your web server may be behind a proxy or firewall, it may
>>> be clustered (and thus you have many machines instead of just one and
>>> they can't all have the same hostname), they may be running on a port >
>>> 1024 because of security concerns, with the firewall redirecting traffic
>>> on port 80 to the webserver.
>>>
>>> Personally I use spring and generally put the hostname/port combination
>>> in a properties file which spring uses to inject it into the application
>>> class. I have different properties files for dev and production which
>>> are activated by different maven profiles.
>>>
>>> However if you really want to do this (which I don't advise) you can use
>>> the HttpServletRequest to find your information using:
>>>
>>>       getWebRequestCycle().getWebRequest().getHttpServletRequest()
>>>
>>> Regards,
>>> Sebastiaan
>>>
>>> Oliver Lieven wrote:
>>>> Hi,
>>>>
>>>> is there a way to determine the complete, absolute URL to a mounted page
>>>> (including protocol, host, port, application, filter and destination
>>>> page)?
>>>> I need this to be able to send a link to a Registration-Confirmation page
>>>> to
>>>> a user via email.
>>>>
>>>> I searched the forum already, but didn't find a working solution. All I
>>>> found were messages saying that since Wicket 1.3 all URLs are relative.
>>>> Reading the JavaDoc I also found various urlFor() and
>>>> getRelativePath...()
>>>> methods, all returning relative paths.
>>>>
>>>> What I would need is a method with a signature similar to
>>>>
>>>>     url = getAbsolutePath(Request request, Class pageClass,
>>>> PageParameters
>>>> parameters)
>>>>
>>>> which returns an url like
>>>> "http://localhost:8080/myapp/app/<page-alias>?...<params>...
>>>>
>>>> Thanks for any hints on this,
>>>> Oliver
>>>>
>>>
>>>
>> --
>> View this message in context: http://www.nabble.com/How-to-determine-absolute-URL-of-a-mounted-page--tf4864119.html#a13920421
>>
>> Sent from the Wicket - User mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
> 

Re: How to determine absolute URL of a mounted page?

Posted by Jonathan Locke <jo...@gmail.com>.

yeah, wicket should be able to find the base url of your application.
i've had to do this in a couple of projects by hand.  /unfortunately/
i don't think there's any container-independent way of doing this 
until a first request has come in for processing.  before that point 
in time, it seems like the absolute url to everything is actually 
undefined.  or maybe there's something i don't know yet... ?


Ryan Sonnek-2 wrote:
> 
> I'm trying to accomplish the same thing and think that wicket should
> provide such an API.  all of the "issues" mentioned are well known
> issues and other web frameworks still provide an API and just
> acknowledge the limitations.
> 
> This is pretty important for me as I can't necessarily "hardcode" the
> url when the application runs in several different environments
> (production vs development for example).  please vote for this JIRA
> issue and hopefully we can get some kind of API added.
> https://issues.apache.org/jira/browse/WICKET-609
> 
> 
> On Nov 23, 2007 7:03 PM, Oliver Lieven <ol...@provantis.de> wrote:
>>
>> Hi Sebastiaan,
>>
>> thanks for your answer. Excellent point on potential problems when using
>> clusters, firewalls and proxies (I run into those already).
>>
>> I also thought on providing the URLs in a configuration file/spring
>> config,
>> but "feared" there might be a simple and preferred "Wicket" way to
>> determine
>> the URLs.
>>
>> Thanks alot,
>> Oliver
>>
>>
>>
>>
>>
>>
>>
>>
>> Sebastiaan van Erk wrote:
>> >
>> > What's wrong with putting this in a configuration file or just a
>> > constant. Because in general this does not really work.
>> >
>> > For example, your web server may be behind a proxy or firewall, it may
>> > be clustered (and thus you have many machines instead of just one and
>> > they can't all have the same hostname), they may be running on a port >
>> > 1024 because of security concerns, with the firewall redirecting
>> traffic
>> > on port 80 to the webserver.
>> >
>> > Personally I use spring and generally put the hostname/port combination
>> > in a properties file which spring uses to inject it into the
>> application
>> > class. I have different properties files for dev and production which
>> > are activated by different maven profiles.
>> >
>> > However if you really want to do this (which I don't advise) you can
>> use
>> > the HttpServletRequest to find your information using:
>> >
>> >       getWebRequestCycle().getWebRequest().getHttpServletRequest()
>> >
>> > Regards,
>> > Sebastiaan
>> >
>> > Oliver Lieven wrote:
>> >> Hi,
>> >>
>> >> is there a way to determine the complete, absolute URL to a mounted
>> page
>> >> (including protocol, host, port, application, filter and destination
>> >> page)?
>> >> I need this to be able to send a link to a Registration-Confirmation
>> page
>> >> to
>> >> a user via email.
>> >>
>> >> I searched the forum already, but didn't find a working solution. All
>> I
>> >> found were messages saying that since Wicket 1.3 all URLs are
>> relative.
>> >> Reading the JavaDoc I also found various urlFor() and
>> >> getRelativePath...()
>> >> methods, all returning relative paths.
>> >>
>> >> What I would need is a method with a signature similar to
>> >>
>> >>     url = getAbsolutePath(Request request, Class pageClass,
>> >> PageParameters
>> >> parameters)
>> >>
>> >> which returns an url like
>> >> "http://localhost:8080/myapp/app/<page-alias>?...<params>...
>> >>
>> >> Thanks for any hints on this,
>> >> Oliver
>> >>
>> >
>> >
>> >
>>
>> --
>> View this message in context:
>> http://www.nabble.com/How-to-determine-absolute-URL-of-a-mounted-page--tf4864119.html#a13920421
>>
>> Sent from the Wicket - User mailing list archive at Nabble.com.
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/How-to-determine-absolute-URL-of-a-mounted-page--tf4864119.html#a13931992
Sent from the Wicket - User mailing list archive at Nabble.com.


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


Re: How to determine absolute URL of a mounted page?

Posted by Ryan Sonnek <ry...@gmail.com>.
I'm trying to accomplish the same thing and think that wicket should
provide such an API.  all of the "issues" mentioned are well known
issues and other web frameworks still provide an API and just
acknowledge the limitations.

This is pretty important for me as I can't necessarily "hardcode" the
url when the application runs in several different environments
(production vs development for example).  please vote for this JIRA
issue and hopefully we can get some kind of API added.
https://issues.apache.org/jira/browse/WICKET-609


On Nov 23, 2007 7:03 PM, Oliver Lieven <ol...@provantis.de> wrote:
>
> Hi Sebastiaan,
>
> thanks for your answer. Excellent point on potential problems when using
> clusters, firewalls and proxies (I run into those already).
>
> I also thought on providing the URLs in a configuration file/spring config,
> but "feared" there might be a simple and preferred "Wicket" way to determine
> the URLs.
>
> Thanks alot,
> Oliver
>
>
>
>
>
>
>
>
> Sebastiaan van Erk wrote:
> >
> > What's wrong with putting this in a configuration file or just a
> > constant. Because in general this does not really work.
> >
> > For example, your web server may be behind a proxy or firewall, it may
> > be clustered (and thus you have many machines instead of just one and
> > they can't all have the same hostname), they may be running on a port >
> > 1024 because of security concerns, with the firewall redirecting traffic
> > on port 80 to the webserver.
> >
> > Personally I use spring and generally put the hostname/port combination
> > in a properties file which spring uses to inject it into the application
> > class. I have different properties files for dev and production which
> > are activated by different maven profiles.
> >
> > However if you really want to do this (which I don't advise) you can use
> > the HttpServletRequest to find your information using:
> >
> >       getWebRequestCycle().getWebRequest().getHttpServletRequest()
> >
> > Regards,
> > Sebastiaan
> >
> > Oliver Lieven wrote:
> >> Hi,
> >>
> >> is there a way to determine the complete, absolute URL to a mounted page
> >> (including protocol, host, port, application, filter and destination
> >> page)?
> >> I need this to be able to send a link to a Registration-Confirmation page
> >> to
> >> a user via email.
> >>
> >> I searched the forum already, but didn't find a working solution. All I
> >> found were messages saying that since Wicket 1.3 all URLs are relative.
> >> Reading the JavaDoc I also found various urlFor() and
> >> getRelativePath...()
> >> methods, all returning relative paths.
> >>
> >> What I would need is a method with a signature similar to
> >>
> >>     url = getAbsolutePath(Request request, Class pageClass,
> >> PageParameters
> >> parameters)
> >>
> >> which returns an url like
> >> "http://localhost:8080/myapp/app/<page-alias>?...<params>...
> >>
> >> Thanks for any hints on this,
> >> Oliver
> >>
> >
> >
> >
>
> --
> View this message in context: http://www.nabble.com/How-to-determine-absolute-URL-of-a-mounted-page--tf4864119.html#a13920421
>
> Sent from the Wicket - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

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


Re: How to determine absolute URL of a mounted page?

Posted by Oliver Lieven <ol...@provantis.de>.
Hi Sebastiaan,

thanks for your answer. Excellent point on potential problems when using
clusters, firewalls and proxies (I run into those already).

I also thought on providing the URLs in a configuration file/spring config,
but "feared" there might be a simple and preferred "Wicket" way to determine
the URLs. 

Thanks alot,
Oliver







Sebastiaan van Erk wrote:
> 
> What's wrong with putting this in a configuration file or just a 
> constant. Because in general this does not really work.
> 
> For example, your web server may be behind a proxy or firewall, it may 
> be clustered (and thus you have many machines instead of just one and 
> they can't all have the same hostname), they may be running on a port > 
> 1024 because of security concerns, with the firewall redirecting traffic 
> on port 80 to the webserver.
> 
> Personally I use spring and generally put the hostname/port combination 
> in a properties file which spring uses to inject it into the application 
> class. I have different properties files for dev and production which 
> are activated by different maven profiles.
> 
> However if you really want to do this (which I don't advise) you can use 
> the HttpServletRequest to find your information using:
> 
> 	getWebRequestCycle().getWebRequest().getHttpServletRequest()
> 
> Regards,
> Sebastiaan
> 
> Oliver Lieven wrote:
>> Hi,
>> 
>> is there a way to determine the complete, absolute URL to a mounted page
>> (including protocol, host, port, application, filter and destination
>> page)?
>> I need this to be able to send a link to a Registration-Confirmation page
>> to
>> a user via email. 
>> 
>> I searched the forum already, but didn't find a working solution. All I
>> found were messages saying that since Wicket 1.3 all URLs are relative.
>> Reading the JavaDoc I also found various urlFor() and
>> getRelativePath...()
>> methods, all returning relative paths.
>> 
>> What I would need is a method with a signature similar to
>> 
>>     url = getAbsolutePath(Request request, Class pageClass,
>> PageParameters
>> parameters)
>> 
>> which returns an url like 
>> "http://localhost:8080/myapp/app/<page-alias>?...<params>...
>> 
>> Thanks for any hints on this,
>> Oliver
>> 
> 
>  
> 

-- 
View this message in context: http://www.nabble.com/How-to-determine-absolute-URL-of-a-mounted-page--tf4864119.html#a13920421
Sent from the Wicket - User mailing list archive at Nabble.com.


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


Re: How to determine absolute URL of a mounted page?

Posted by Sebastiaan van Erk <se...@sebster.com>.
What's wrong with putting this in a configuration file or just a 
constant. Because in general this does not really work.

For example, your web server may be behind a proxy or firewall, it may 
be clustered (and thus you have many machines instead of just one and 
they can't all have the same hostname), they may be running on a port > 
1024 because of security concerns, with the firewall redirecting traffic 
on port 80 to the webserver.

Personally I use spring and generally put the hostname/port combination 
in a properties file which spring uses to inject it into the application 
class. I have different properties files for dev and production which 
are activated by different maven profiles.

However if you really want to do this (which I don't advise) you can use 
the HttpServletRequest to find your information using:

	getWebRequestCycle().getWebRequest().getHttpServletRequest()

Regards,
Sebastiaan

Oliver Lieven wrote:
> Hi,
> 
> is there a way to determine the complete, absolute URL to a mounted page
> (including protocol, host, port, application, filter and destination page)?
> I need this to be able to send a link to a Registration-Confirmation page to
> a user via email. 
> 
> I searched the forum already, but didn't find a working solution. All I
> found were messages saying that since Wicket 1.3 all URLs are relative.
> Reading the JavaDoc I also found various urlFor() and getRelativePath...()
> methods, all returning relative paths.
> 
> What I would need is a method with a signature similar to
> 
>     url = getAbsolutePath(Request request, Class pageClass, PageParameters
> parameters)
> 
> which returns an url like 
> "http://localhost:8080/myapp/app/<page-alias>?...<params>...
> 
> Thanks for any hints on this,
> Oliver
>