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)
| 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 |
nothing calls this directly
no test coverage detected