String contextPath = _request.getContextPath(); int posContextInUrl=_currentUrl.indexOf(contextPath); _existBaseUrl = _currentUrl.substring(0, posContextInUrl) + contextPath;
int webstartPos = _currentUrl.indexOf("/webstart"); _existBaseUrl = _currentUrl.substring(0, webstartPos);
    public JnlpHelper(JnlpFiles jnlpFiles, HttpServletRequest request) {                // Store objects        _jnlpFiles=jnlpFiles;        _request=request;                // Format URL: "http://host:8080/CONTEXT/webstart/exist.jnlp"        _currentUrl = _request.getRequestURL().toString();                // Find position of "/CONTEXT", construct URL to exist Base URL        String contextPath = _request.getContextPath();        int posContextInUrl=_currentUrl.indexOf(contextPath);        _existBaseUrl = _currentUrl.substring(0, posContextInUrl) + contextPath;                // Find URL to ...../webstart for first line jnlp-file        int position = _currentUrl.lastIndexOf("/");        _codeBase = _currentUrl.substring(0, position+1);        _href = _currentUrl.substring(position+1);                // Find URL to connect to with client               _startUrl = _existBaseUrl.replaceFirst("http:", "xmldb:exist:") + "/xmlrpc";    }