url

toc
<mm:url>

Returns an URL with parameters from the context. Parameters can be specified in three ways:

  • Simply write it in the `page' attribute (with ? and &amp; (or simply & if you don't produce XHTML), you can use the $-notation to refer to context variable values.
  • Use the `referids' attribute to specify a list of context variables to add to the URL. The disadvantage is that you can't use another name for the parameter then the name of the variable.
  • Use `mm:param' sub-tags.

This tag also takes care of the `application' context if you start the page attribute with `/'. This makes your applications better portable.

It also does an URLEncode, which can be necessary if the browsers does not support cookies and your page needs the session.

You don't need it for URLs outside your application server application. It is very advisable to use it otherwise.

By use of the servlet context init parameter mmbase.taglib.url.makerelative (value `true'), you can change the behaviour of all url-tags, to make them generate url's relative to the current page.

see alsoparam | image | link | url
attributes
  • referids

    Specify which parameters. A comma separated list of context variable id's.

    Since MMBase-1.7 you can also rename the variable on the fly. Putting a variable `a' as `b' in the url can be done with `a@b' (generating b=<value of a> in stead of a=<value of a>)

    If a context variable does not exist, it is ignored if you postfix it with `?'. This makes it possible to make more general includes, while maintaining syntax checking as much as possible.


  • page
    The url to refer to. If not specified, then it becomes the result of getRequestURI.
  • block
    The block to create an URL to. This can only be used from within MMBase components, where the current component block needs to generate a link to another block of the same component.
  • referid (since: MMBase-1.7)
    Reuses another mm:url (via its id). You can add extra parameters then, or simply make another link (this last thing could also be done with mm:write). This attribute cannot be used together with the `page' attribute.
  • escapeamps
    Whether or not to escape &'s in the query string. According to XHTML is must. But perhaps you don't want XHTML but something else. Default it is true.
  • encode (since: MMBase-1.8)
    Whether or not to encode the url. According to the servlet specification all urls should be encoded, but this also adds a session id to the url when cookies are not supported. Many web servers can not handle them and prevent caching of static resources. Default it is true.
  • absolute (since: MMBase-1.8)
    Whether or not to produce fully qualified absolute URLs. (http://myhost.nl/context/..). Defaults to false.
    falseDoes nothing special to the url. If 'page' starts with '/' the context is prefixed.
    trueMakes the URL absolute, so it starts with something like http:
    serverMakes the URL absolute on the server, so it starts with /.
    contextMakes the URL absolute on the current servlet context, so it starts with /, but it is not prefixed by the context. The result could e.g. be used as an argument for another url-tag.
  • internal (since: MMBase-1.9)

writer attributes
contextwriter attributes
contextreferrer attributes
cloudreferrer attributes
example 1
<mm:url referids="a?,name@b,c" page="codesamples/index.jsp">
 <mm:param name="page" value="home" />
</mm:url>
    generates e.g. : codesamples/index.jsp?page=home&b=jan&c=5