Hi,
The SlingHttpServletResponseImpl actually implements the
HttpServletResponse.encodeURL method with exactly this semantics. Here
is the code of this method :
public String encodeURL(String url) {
// make the path absolute
url = makeAbsolutePath(url);
// resolve the url to as if it would be a resource path
url = map(url);
// have the servlet container to further encodings
return super.encodeURL(url);
}
The encodeRedirectURL is implemented similarly.
Currently the URL is not prefixed with the context path.
Questions:
(1) Would this be, what you envisioned ?
(2) Obviously this implementation is not exactly what the Spec says, the
encodeURL method is about: encodeURL is used to rewrite the URL to add
the Session ID.
WDYT ?
Regards
Felix
Alexander Klimetschek (JIRA) schrieb:
> Add externalizeHref() to SlingHttpServletResponse
> -------------------------------------------------
>
> Key: SLING-696
> URL: https://issues.apache.org/jira/browse/SLING-696
> Project: Sling
> Issue Type: New Feature
> Components: API, Engine
> Reporter: Alexander Klimetschek
>
>
> A SlingHttpServletResponse.externalizeHref() method, that correctly maps a
> JCR resource path back to the URL that has to be used externally to access
> that resource, would be very helpful for use in HTML rendering scripts and
> servlets.
>
> The implementation would need to:
> - reverse map any resource resolver mappings, ie. call ResourceResolver.map()
> - add the servlet context path at the beginning
> - (maybe check if the resource actually exists)
>
> (I hope this list is complete)
>