code: public String getTemplatedURL( ServletContext servletContext,
                                     ServletRequest request, MutableURI uri,
                                     String key, URIContext uriContext )
      {
          // Look for the template config and get the right template.
          // If it is found, apply the value to the template.
          String result = null;
          URLTemplate template = null;
          URLTemplatesFactory factory = URLTemplatesFactory.getURLTemplatesFactory( request );
  
          if ( factory != null )
          {
              String templateName = factory.getTemplateNameByRef( DEFAULT_TEMPLATE_REF, key );
  
              if ( templateName != null )
              {
                  template = factory.getURLTemplate( templateName );
              }
          }
  
          if ( template != null )
          {
              result = formatURIWithTemplate( request, uri, uriContext, template );
          }
          else
          {
              // no template found, just return the uri as a String...
              result = uri.getURIString( uriContext );
          }
  
          return result;
      }
docs: Format the given URL using a URL template, if defined in a URL
  template config file. The {@link org.apache.beehive.netui.core.urls.URIContext}
  encapsulates some additional data needed to write out the string form.
  E.g. It defines if the &quot;&amp;amp;&quot; entity or the
  '&amp;' character should be used to separate quary parameters.
  
  @param servletContext the current ServletContext.
  @param request the current ServletRequest.
  @param uri the MutableURI to be formatted into a String.
  @param key key for the URL template type to use for formatting the URI
  @param uriContext data required to write out the string form.
  @return the URL as a <code>String</code>