bundles/org.apache.jasper.glassfish/src/org/apache/jasper/runtime/JspRuntimeLibrary.java
public static String getContextRelativePath(ServletRequest request,
                                                String relativePath) {

        if (relativePath.startsWith("/"))
            return (relativePath);
        if (!(request instanceof HttpServletRequest))
            return (relativePath);
        HttpServletRequest hrequest = (HttpServletRequest) request;
        String uri = (String)
            request.getAttribute("javax.servlet.include.servlet_path");
        if (uri != null) {
            String pathInfo = (String)
                request.getAttribute("javax.servlet.include.path_info");
            if (pathInfo == null) {
                if (uri.lastIndexOf('/') >= 0) {
                    uri = uri.substring(0, uri.lastIndexOf('/'));
                }
            }
        }
        else {
            // STARTJR: fix improper handling of jsp:include
            uri = hrequest.getServletPath();
            String pathInfo = hrequest.getPathInfo ();
            if ( pathInfo != null) {
                uri = uri + pathInfo;
            }
            if (uri.lastIndexOf('/') >= 0) {
                uri = uri.substring(0, uri.lastIndexOf('/'));
            }
            // ENDJR
        }
        return uri + '/' + relativePath;

    }
public static String getContextRelativePath(ServletRequest request,
                                                String relativePath) {

        if (relativePath.startsWith("/"))
            return (relativePath);
        if (!(request instanceof HttpServletRequest))
            return (relativePath);
        HttpServletRequest hrequest = (HttpServletRequest) request;
        String uri = (String)
            request.getAttribute("javax.servlet.include.servlet_path");
        if (uri != null) {
            String pathInfo = (String)
                request.getAttribute("javax.servlet.include.path_info");
            if (pathInfo == null) {
                if (uri.lastIndexOf('/') >= 0) {
                    uri = uri.substring(0, uri.lastIndexOf('/'));
                }
            }
        }
        else {
            // STARTJR: fix improper handling of jsp:include
            uri = hrequest.getServletPath();
            String pathInfo = hrequest.getPathInfo ();
            if ( pathInfo != null) {
                uri = uri + pathInfo;
            }
            if (uri.lastIndexOf('/') >= 0) {
                uri = uri.substring(0, uri.lastIndexOf('/'));
            }
            // ENDJR
        }
        return uri + '/' + relativePath;

    }
public static String getContextRelativePath ( ServletRequest request , String relativePath ) { if ( relativePath . startsWith ( "/" ) ) return ( relativePath ) ; if ( ! ( request instanceof HttpServletRequest ) ) return ( relativePath ) ; HttpServletRequest hrequest = ( HttpServletRequest ) request ; String uri = ( String ) request . getAttribute ( "javax.servlet.include.servlet_path" ) ; if ( uri != null ) { String pathInfo = ( String ) request . getAttribute ( "javax.servlet.include.path_info" ) ; if ( pathInfo == null ) { if ( uri . lastIndexOf ( ' ' ) >= 0 ) { uri = uri . substring ( 0 , uri . lastIndexOf ( ' ' ) ) ; } } } else { // STARTJR: fix improper handling of jsp:include uri = hrequest . getServletPath ( ) ; String pathInfo = hrequest . getPathInfo ( ) ; if ( pathInfo != null ) { uri = uri + pathInfo ; } if ( uri . lastIndexOf ( ' ' ) >= 0 ) { uri = uri . substring ( 0 , uri . lastIndexOf ( ' ' ) ) ; } // ENDJR } return uri + ' ' + relativePath ; }
Convert a possibly relative resource path into a context-relative
resource path that starts with a '/'.

@param request The servlet request we are processing
@param relativePath The possibly relative resource path
Convert a possibly relative resource path into a context - relative resource path that starts with a / .