You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Maxim Solodovnik <so...@gmail.com> on 2014/03/12 17:14:12 UTC

The wicket way of getting application base URL

Hello,

I'm currently using SelfUpdatingAjaxBehavior [1] to get application base
URL used by the end user.

Maybe there is more standard way of doing this?
Or maybe code like this can be added to ClientInfo?

Thanks in advance!

[1]
https://svn.apache.org/viewvc/openmeetings/trunk/singlewebapp/src/web/java/org/apache/openmeetings/web/util/BaseUrlAjaxBehavior.java?view=markup

-- 
WBR
Maxim aka solomax

Re: The wicket way of getting application base URL

Posted by Maxim Solodovnik <so...@gmail.com>.
Thanks!
Has added config option


On Thu, Mar 13, 2014 at 8:39 PM, Chris Snyder <ch...@biologos.org>wrote:

> I think that such a configuration option is likely your only choice, and is
> something I often see in other webapps. The only other option I can think
> of would be if the proxy was passing a header with the original requested
> URL. However, I don't see such functionality in mod_proxy (at least from a
> quick skim of its documentation).
>
> I can imagine a hacky way of using Javascript to pass it in. I'm only
> mentioning it to dissuade you from considering it (if you were), as it
> would be a huge security risk: Someone could send incorrect data to the
> server, causing it to send out the wrong URLs. That would make for an
> effective phishing campaign - emails from a legitimate source with links to
> the cracker's server.
>
> Best,
> Chris
>
>
> On Thu, Mar 13, 2014 at 9:22 AM, jchappelle <jc...@4redi.com> wrote:
>
> > We just use a configuration property in our application that is stored in
> > our
> > "properties" database table. So our solution really doesn't involve
> wicket
> > at all.
> >
> > --
> > View this message in context:
> >
> http://apache-wicket.1842946.n4.nabble.com/The-wicket-way-of-getting-application-base-URL-tp4664925p4664938.html
> > Sent from the Users forum 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
> >
> >
>
>
> --
> Chris Snyder
> Web Developer, BioLogos
> biologos.org
>



-- 
WBR
Maxim aka solomax

Re: The wicket way of getting application base URL

Posted by Chris Snyder <ch...@biologos.org>.
I think that such a configuration option is likely your only choice, and is
something I often see in other webapps. The only other option I can think
of would be if the proxy was passing a header with the original requested
URL. However, I don't see such functionality in mod_proxy (at least from a
quick skim of its documentation).

I can imagine a hacky way of using Javascript to pass it in. I'm only
mentioning it to dissuade you from considering it (if you were), as it
would be a huge security risk: Someone could send incorrect data to the
server, causing it to send out the wrong URLs. That would make for an
effective phishing campaign - emails from a legitimate source with links to
the cracker's server.

Best,
Chris


On Thu, Mar 13, 2014 at 9:22 AM, jchappelle <jc...@4redi.com> wrote:

> We just use a configuration property in our application that is stored in
> our
> "properties" database table. So our solution really doesn't involve wicket
> at all.
>
> --
> View this message in context:
> http://apache-wicket.1842946.n4.nabble.com/The-wicket-way-of-getting-application-base-URL-tp4664925p4664938.html
> Sent from the Users forum 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
>
>


-- 
Chris Snyder
Web Developer, BioLogos
biologos.org

Re: The wicket way of getting application base URL

Posted by jchappelle <jc...@4redi.com>.
We just use a configuration property in our application that is stored in our
"properties" database table. So our solution really doesn't involve wicket
at all.

--
View this message in context: http://apache-wicket.1842946.n4.nabble.com/The-wicket-way-of-getting-application-base-URL-tp4664925p4664938.html
Sent from the Users forum 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: The wicket way of getting application base URL

Posted by Maxim Solodovnik <so...@gmail.com>.
The reason I have implemented the hook:

Our users are using mod_proxy all the time
So port and context are might be changed and I need to get the base URL
after all these modifications (to create emails with links etc.)


On Wed, Mar 12, 2014 at 11:24 PM, Sebastien <se...@gmail.com> wrote:

> Hi Maxim,
>
> Maybe you might use something like this:
> Url baseUrl = new
> Url(page.getRequestCycle().getUrlRenderer().getBaseUrl());
>
> I used it to retrieve the relative url:
>
>     private static String getUrl(WebPage page)
>     {
>         Url pageUrl = Url.parse(page.urlFor(page.getClass(),
> null).toString());
>         Url baseUrl = new
> Url(page.getRequestCycle().getUrlRenderer().getBaseUrl());
>
>         baseUrl.resolveRelative(pageUrl);
>
>         return String.format("%s/%s", page.getRequest().getContextPath(),
> baseUrl);
>     }
>
>
> Best regards,
> Sebastien.
>
>
> On Wed, Mar 12, 2014 at 5:14 PM, Maxim Solodovnik <solomax666@gmail.com
> >wrote:
>
> > Hello,
> >
> > I'm currently using SelfUpdatingAjaxBehavior [1] to get application base
> > URL used by the end user.
> >
> > Maybe there is more standard way of doing this?
> > Or maybe code like this can be added to ClientInfo?
> >
> > Thanks in advance!
> >
> > [1]
> >
> >
> https://svn.apache.org/viewvc/openmeetings/trunk/singlewebapp/src/web/java/org/apache/openmeetings/web/util/BaseUrlAjaxBehavior.java?view=markup
> >
> > --
> > WBR
> > Maxim aka solomax
> >
>



-- 
WBR
Maxim aka solomax

Re: The wicket way of getting application base URL

Posted by Sebastien <se...@gmail.com>.
Hi Maxim,

Maybe you might use something like this:
Url baseUrl = new Url(page.getRequestCycle().getUrlRenderer().getBaseUrl());

I used it to retrieve the relative url:

    private static String getUrl(WebPage page)
    {
        Url pageUrl = Url.parse(page.urlFor(page.getClass(),
null).toString());
        Url baseUrl = new
Url(page.getRequestCycle().getUrlRenderer().getBaseUrl());

        baseUrl.resolveRelative(pageUrl);

        return String.format("%s/%s", page.getRequest().getContextPath(),
baseUrl);
    }


Best regards,
Sebastien.


On Wed, Mar 12, 2014 at 5:14 PM, Maxim Solodovnik <so...@gmail.com>wrote:

> Hello,
>
> I'm currently using SelfUpdatingAjaxBehavior [1] to get application base
> URL used by the end user.
>
> Maybe there is more standard way of doing this?
> Or maybe code like this can be added to ClientInfo?
>
> Thanks in advance!
>
> [1]
>
> https://svn.apache.org/viewvc/openmeetings/trunk/singlewebapp/src/web/java/org/apache/openmeetings/web/util/BaseUrlAjaxBehavior.java?view=markup
>
> --
> WBR
> Maxim aka solomax
>