MCPcopy Create free account
hub / github.com/apache/tomcat / resolveUrl

Method resolveUrl

java/org/apache/jasper/tagplugins/jstl/Util.java:264–291  ·  view source on GitHub ↗

Utility methods taken from org.apache.taglibs.standard.tag.common.core.UrlSupport @param url The URL @param context The context @param pageContext The page context @return the absolute URL @throws JspException If the URL doesn't start with '/'

(String url, String context, PageContext pageContext)

Source from the content-addressed store, hash-verified

262 * @throws JspException If the URL doesn't start with '/'
263 */
264 public static String resolveUrl(String url, String context, PageContext pageContext) throws JspException {
265 // don't touch absolute URLs
266 if (isAbsoluteUrl(url)) {
267 return url;
268 }
269
270 // normalize relative URLs against a context root
271 HttpServletRequest request = (HttpServletRequest) pageContext.getRequest();
272 if (context == null) {
273 if (url.startsWith("/")) {
274 return request.getContextPath() + url;
275 } else {
276 return url;
277 }
278 } else {
279 if (!context.startsWith("/") || !url.startsWith("/")) {
280 throw new JspTagException(Localizer.getMessage("jstl.urlMustStartWithSlash"));
281 }
282 if (context.equals("/")) {
283 // Don't produce string starting with '//', many
284 // browsers interpret this as host name, not as
285 // path on same host.
286 return url;
287 } else {
288 return context + url;
289 }
290 }
291 }
292
293 /**
294 * Wraps responses to allow us to retrieve results as Strings. Mainly taken from

Callers

nothing calls this directly

Calls 6

isAbsoluteUrlMethod · 0.95
getContextPathMethod · 0.95
getMessageMethod · 0.95
getRequestMethod · 0.65
equalsMethod · 0.65
startsWithMethod · 0.45

Tested by

no test coverage detected