public String toAbsoluteURI(String uri, boolean skipInclude) { if (uri != null && uri.length() > 0) { final char cc = uri.charAt(0); if (cc != '/' && cc != '~' && !(skipInclude && isIncluded()) && !Servlets.isUniversalURL(uri)) { final String dir = getDesktop().getCurrentDirectory(); if (dir != null) return dir + uri; } } return uri; //we ignore _creating, because Servlet's include cannot handle //related URI correctly (even though it is by the layout servlet) }
/** Returns the download URI of the specified file. * @param path the path to access the resource of the Web application. * In other words, it is URI of ServletContext. * Since 3.6.1: if the path is relative, {@link Desktop#getCurrentDirectory} is assumed. */ public static String getDownloadURI(String path, String contentType, String data) { if (!path.startsWith("/")) { final String dir = Executions.getCurrent().getDesktop().getCurrentDirectory(); if (dir != null) path = dir + path; } return getDownloadURI('p', path, contentType, data); } private static String
/** Returns the locator for the specified context. * * @param path the original path, or null if not available. * The original path is used to resolve a relative path. * If not specified, {@link org.zkoss.zk.ui.Desktop#getCurrentDirectory} * is used. */ public static final Locator getLocator(WebApp wapp, String path) { if (wapp == null) throw new IllegalArgumentException("null"); if (path != null && path.length() > 0 && path.charAt(0) == '/') { final int j = path.lastIndexOf('/'); path = j > 0 ? path.substring(0, j + 1) : "/"; } else { final Execution exec = Executions.getCurrent(); if (exec != null) path = exec.getDesktop().getCurrentDirectory(); } return new ServletContextLocator(wapp.getServletContext(), path); }