protected String getEmbeddedId(
            final HttpServletRequest servletRequest, final Prefix prefix) {
        String requestPath = servletRequest.getPathInfo();

        // http://stackoverflow.com/questions/18963562/grizzlys-request-getpathinfo-returns-always-null
        if (requestPath == null && servletRequest.getContextPath().isEmpty()) {
            requestPath = servletRequest.getRequestURI();
        }

        String id = null;
        if (requestPath != null) {
            final String pathPrefix = prefix.getPrefix();
            final String[] part = requestPath.split("/");
            if (part.length > 1 && part[1].startsWith(pathPrefix)) {
                id = part[1].substring(pathPrefix.length());
            }
        }
        return id;
    }
protected String getEmbeddedId ( final HttpServletRequest servletRequest , final Prefix prefix ) { String requestPath = servletRequest . getPathInfo ( ) ; if ( requestPath == null && servletRequest . getContextPath ( ) . isEmpty ( ) ) { requestPath = servletRequest . getRequestURI ( ) ; } String id = null ; if ( requestPath != null ) { final String pathPrefix = prefix . getPrefix ( ) ; final String [ ] part = requestPath . split ( "/" ) ; if ( part . length > 1 && part [ 1 ] . startsWith ( pathPrefix ) ) { id = part [ 1 ] . substring ( pathPrefix . length ( ) ) ; } } return id ; }
Extract the id embedded at the beginning of a request path

@param servletRequest the servlet request
@param prefix the prefix for the id
@return the found id or null