Search in sources :

Example 1 with HttpServlet

use of org.xipki.http.servlet.HttpServlet in project xipki by xipki.

the class ServletListener method getServlet.

public Object[] getServlet(String rawPath) throws URISyntaxException {
    String alias = null;
    String uriText = null;
    for (String m : aliases) {
        if (m.equals("/")) {
            alias = m;
            uriText = rawPath;
            break;
        }
        if (rawPath.startsWith(m)) {
            int len = rawPath.length();
            int mlen = m.length();
            if (len == mlen) {
                uriText = "/";
                alias = m;
            } else {
                char ch = rawPath.charAt(mlen);
                if (ch == '/') {
                    uriText = (len == mlen + 1) ? "/" : rawPath.substring(mlen);
                    alias = m;
                } else if (ch == '?') {
                    uriText = rawPath.substring(mlen);
                    alias = m;
                }
            }
        }
        if (alias != null) {
            break;
        }
    }
    if (alias == null) {
        return null;
    }
    ServletURI servletUri = ServletURIPool.getServletURI(uriText);
    HttpServlet servlet = aliasServletMap.get(alias);
    return new Object[] { servletUri, servlet };
}
Also used : ServletURI(org.xipki.http.servlet.ServletURI) HttpServlet(org.xipki.http.servlet.HttpServlet)

Aggregations

HttpServlet (org.xipki.http.servlet.HttpServlet)1 ServletURI (org.xipki.http.servlet.ServletURI)1