// ------------------------------------------ public static String chooseServiceURI(String uri, HttpServletRequest httpRequest) { String serviceURI = uri; String contextPath = httpRequest.getContextPath(); if (contextPath != null && contextPath.length() > 0) serviceURI = serviceURI.substring(contextPath.length()); String servletPath = httpRequest.getServletPath(); // Suggested by Frank Hartman: helps make conf files more portable // between /joseki/myModel and /myModel but if the servlet is // explicitly named in web.xml, it strips that off // if ( servletPath != null && servletPath.length() > 0 ) // dispatchURI = dispatchURI.substring(servletPath.length()) ; // Suggested by damien_coraboeuf // TODO Test and verify // if ( servletPath != null && servletPath.length() > 0 ) // serviceURI = serviceURI.substring(servletPath.length()) ; // Example: // <servlet-mapping> // <servlet-name>JosekiServlet</servlet-name> // <url-pattern>/ws/joseki/*</url-pattern> // </servlet-mapping> if (log.isDebugEnabled()) { if (servletPath == null) servletPath = ""; if (contextPath == null) contextPath = ""; log.debug( "DispatchURI: " + uri + " => " + serviceURI + " (ContextPath = " + contextPath + ", ServletPath = " + servletPath + ")"); } return serviceURI; }