This Confluence has been LDAP enabled, if you are an ASF Committer, please use your LDAP Credentials to login. Any problems file an INFRA jira ticket please.

Child pages
  • Getting a url for display
Skip to end of metadata
Go to start of metadata

Getting Web Page URL as String

Always a favorite of mine to get a page url, and send in an email, or re-display back in the current page. Any way you shake it, it becomes useful when building applications. So here goes with an example:

class MyPage extends WebPage {

    public MyPage() {
         String url = urlFor("pageMapName", MyPage.class, new PageParameters("foo=bar"));

Please notice that since Wicket 1.3, the URLs provided by Wicket are always relative. Indeed, wicket can't provide absolute path because the website can be behind proxies or virtual hosted.

Still, this can be then sent in an email, displayed back to the user, saved to a database, whatever you desire. You can also do so from within a Form subclass

class MyPage extends WebPage {
   public MyPage() {

   private class MyForm extends Form {
       public void onSubmit() {
           String url = getPage().urlFor("pageMapName", MyPage.class, new PageParameters("foo=bar"));

Did you know you can define page class alias to not expose your package structure in the URL? Just use application.getPages().putClassAlias(MyPage.class, "myAlias"); The URL will than look like http://.../myApp?bookmarkablePage=myAlias

Absolute paths


Absolute paths with Wicket > 1.5

THe RequestUtils method with only one parameter has been removed. To get the same output, it is recommended to use the following code:


If you would like to work in a similar way as before 1.5, you can use the following method:

public final static String toAbsolutePath(final String relativePagePath) {
       HttpServletRequest req = (HttpServletRequest)((WebRequest)RequestCycle.get().getRequest()).getContainerRequest();
       return RequestUtils.toAbsolutePath(req.getRequestURL().toString(), relativePagePath);
  • No labels

1 Comment

  1. I don't know where to put

    application.getPages().putClassAlias(MyPage.class, "myAlias");?

    is it obsolete for wicket 6.7?