<< Back - Alkacon logo

OpenCms 6.0 interactive documentation:

Documentation for the link() method

OpenCms logo - Forward >>

The link() method

This method acts as a wrapper to build a valid OpenCms URL for a given internal VFS resource. This allows you to set URLs without having to add the name of the web application and servlet context manually. Second, if a page is exported into a static HTML page by OpenCms, a URL returned by the  link() method will be replaced by it's static link target.

Note: the link() method cannot be used for external links to other domains!

Parameters:

Name Description
java.lang.String link The URI of the resource in the OpenCms VFS.

Example usage:

Build a valid URL for a resource in the current folder:

org.opencms.jsp.CmsJspActionElement cms = new org.opencms.jsp.CmsJspActionElement(pageContext, request, response);

out.println(cms.link("index.html"));

Build a valid URL for a resource in another folder:

org.opencms.jsp.CmsJspActionElement cms = new org.opencms.jsp.CmsJspActionElement(pageContext, request, response);

out.println(cms.link("/some/other/folder/index.html"));

Build a valid URL for a resource in the root folder:

org.opencms.jsp.CmsJspActionElement cms = new org.opencms.jsp.CmsJspActionElement(pageContext, request, response);

out.println(cms.link("/index.html"));

©2003-2005 Alkacon Software (http://www.alkacon.com) - The OpenCms experts