What about a helper class (static methods) or a jsp taglib?

Regards
Carsten

Alexander Klimetschek  wrote
> Hi all,
> 
> I'd like to have a method on the SlingHttpServletRequest that
> externalizes URLs, ie. just as map() in the resource resolver it
> converts an internal resource path into a fully valid URL for access
> from the outside:
> 
> relative: /my/sub/path => /contextpath/my/sub/path
> absolute: /my/sub/path => http://server.com/contextpath/my/sub/path
> 
> For URLs relative to the current request, this is already possible by
> using one of the resource resolver map() methods:
> 
> slingRequest.getResourceResolver().map(slingRequest, "/my/path"))
> 
> ...which is a bit clunky for placing it into JSPs.
> 
> For absolute URLs, that must include a host/port, using map() is not
> enough. If no host -> path mapping is configured (eg. myserver.80/ ->
> / in /etc/map), you'd typically like to use the current request as the
> default, which isn't done by any of the map() methods.
> 
> Also, if a hostname is configured and you use the map(request, path),
> because that is required for adding the context path, it will _strip_
> it from the map call if the current request goes to that hostname,
> which is probably the normal case (this is correct, as the
> map(request, path) call is aimed at relative URLs).
> 
> Therefore additional methods on the request object make sense, I think.
> 
> See https://issues.apache.org/jira/browse/SLING-1629 for a patch.
> 
> WDYT?
> 
> Regards,
> Alex
> 


-- 
Carsten Ziegeler
cziege...@apache.org

Reply via email to