Search in sources :

Example 1 with RequestInfo

use of org.apache.felix.http.base.internal.dispatch.RequestInfo in project felix by apache.

the class ServletContextImpl method getNamedDispatcher.

@Override
public RequestDispatcher getNamedDispatcher(final String name) {
    if (name == null) {
        return null;
    }
    final RequestDispatcher dispatcher;
    final ServletHandler servletHandler = this.handlerRegistry.resolveServletByName(name);
    if (servletHandler != null) {
        final ServletResolution resolution = new ServletResolution();
        resolution.handler = servletHandler;
        resolution.handlerRegistry = this.handlerRegistry;
        // TODO - what is the path of a named servlet?
        final RequestInfo requestInfo = new RequestInfo("", null, null, null);
        dispatcher = new RequestDispatcherImpl(resolution, requestInfo);
    } else {
        dispatcher = null;
    }
    return dispatcher;
}
Also used : ServletResolution(org.apache.felix.http.base.internal.registry.ServletResolution) ServletHandler(org.apache.felix.http.base.internal.handler.ServletHandler) RequestInfo(org.apache.felix.http.base.internal.dispatch.RequestInfo) RequestDispatcher(javax.servlet.RequestDispatcher) RequestDispatcherImpl(org.apache.felix.http.base.internal.dispatch.RequestDispatcherImpl)

Example 2 with RequestInfo

use of org.apache.felix.http.base.internal.dispatch.RequestInfo in project felix by apache.

the class SharedServletContextImpl method getRequestDispatcher.

@Override
public RequestDispatcher getRequestDispatcher(String path) {
    // See section 9.1 of Servlet 3.x specification...
    if (path == null || (!path.startsWith("/") && !"".equals(path))) {
        return null;
    }
    String query = null;
    int q = 0;
    if ((q = path.indexOf('?')) > 0) {
        query = path.substring(q + 1);
        path = path.substring(0, q);
    }
    // TODO remove path parameters...
    final String encodedRequestURI = path == null ? "" : removeDotSegments(path);
    final String requestURI = decodePath(encodedRequestURI);
    final RequestDispatcher dispatcher;
    final PathResolution pathResolution = this.registry.resolve(requestURI);
    if (pathResolution != null) {
        final ServletResolution resolution = new ServletResolution();
        resolution.handler = pathResolution.handler;
        resolution.handlerRegistry = this.registry;
        final RequestInfo requestInfo = new RequestInfo(pathResolution.servletPath, pathResolution.pathInfo, query, UriUtils.concat(this.contextPath, encodedRequestURI));
        dispatcher = new RequestDispatcherImpl(resolution, requestInfo);
    } else {
        dispatcher = null;
    }
    return dispatcher;
}
Also used : ServletResolution(org.apache.felix.http.base.internal.registry.ServletResolution) RequestInfo(org.apache.felix.http.base.internal.dispatch.RequestInfo) RequestDispatcher(javax.servlet.RequestDispatcher) PathResolution(org.apache.felix.http.base.internal.registry.PathResolution) RequestDispatcherImpl(org.apache.felix.http.base.internal.dispatch.RequestDispatcherImpl)

Example 3 with RequestInfo

use of org.apache.felix.http.base.internal.dispatch.RequestInfo in project felix by apache.

the class ServletContextImpl method getRequestDispatcher.

@Override
public RequestDispatcher getRequestDispatcher(String path) {
    // See section 9.1 of Servlet 3.x specification...
    if (path == null || (!path.startsWith("/") && !"".equals(path))) {
        return null;
    }
    String query = null;
    int q = 0;
    if ((q = path.indexOf('?')) > 0) {
        query = path.substring(q + 1);
        path = path.substring(0, q);
    }
    // TODO remove path parameters...
    final String encodedRequestURI = path == null ? "" : removeDotSegments(path);
    final String requestURI = decodePath(encodedRequestURI);
    final RequestDispatcher dispatcher;
    final PathResolution pathResolution = this.handlerRegistry.resolve(requestURI);
    if (pathResolution != null) {
        final ServletResolution resolution = new ServletResolution();
        resolution.handler = pathResolution.handler;
        resolution.handlerRegistry = this.handlerRegistry;
        final RequestInfo requestInfo = new RequestInfo(pathResolution.servletPath, pathResolution.pathInfo, query, UriUtils.concat(this.getContextPath(), encodedRequestURI));
        dispatcher = new RequestDispatcherImpl(resolution, requestInfo);
    } else {
        dispatcher = null;
    }
    return dispatcher;
}
Also used : ServletResolution(org.apache.felix.http.base.internal.registry.ServletResolution) RequestInfo(org.apache.felix.http.base.internal.dispatch.RequestInfo) RequestDispatcher(javax.servlet.RequestDispatcher) PathResolution(org.apache.felix.http.base.internal.registry.PathResolution) RequestDispatcherImpl(org.apache.felix.http.base.internal.dispatch.RequestDispatcherImpl)

Example 4 with RequestInfo

use of org.apache.felix.http.base.internal.dispatch.RequestInfo in project felix by apache.

the class SharedServletContextImpl method getNamedDispatcher.

@Override
public RequestDispatcher getNamedDispatcher(final String name) {
    if (name == null) {
        return null;
    }
    final RequestDispatcher dispatcher;
    final ServletHandler servletHandler = this.registry.resolveServletByName(name);
    if (servletHandler != null) {
        final ServletResolution resolution = new ServletResolution();
        resolution.handler = servletHandler;
        resolution.handlerRegistry = this.registry;
        // TODO - what is the path of a named servlet?
        final RequestInfo requestInfo = new RequestInfo("", null, null, null);
        dispatcher = new RequestDispatcherImpl(resolution, requestInfo);
    } else {
        dispatcher = null;
    }
    return dispatcher;
}
Also used : ServletResolution(org.apache.felix.http.base.internal.registry.ServletResolution) ServletHandler(org.apache.felix.http.base.internal.handler.ServletHandler) RequestInfo(org.apache.felix.http.base.internal.dispatch.RequestInfo) RequestDispatcher(javax.servlet.RequestDispatcher) RequestDispatcherImpl(org.apache.felix.http.base.internal.dispatch.RequestDispatcherImpl)

Aggregations

RequestDispatcher (javax.servlet.RequestDispatcher)4 RequestDispatcherImpl (org.apache.felix.http.base.internal.dispatch.RequestDispatcherImpl)4 RequestInfo (org.apache.felix.http.base.internal.dispatch.RequestInfo)4 ServletResolution (org.apache.felix.http.base.internal.registry.ServletResolution)4 ServletHandler (org.apache.felix.http.base.internal.handler.ServletHandler)2 PathResolution (org.apache.felix.http.base.internal.registry.PathResolution)2