Package io.undertow.servlet.handlers

Examples of io.undertow.servlet.handlers.ServletRequestContext


        req.getSession(true).setAttribute(SESSION_KEY, req.getContextPath() + req.getServletPath() + (req.getPathInfo() == null ? "" : req.getPathInfo()));
    }

    @Override
    protected void handleRedirectBack(final HttpServerExchange exchange) {
        final ServletRequestContext servletRequestContext = exchange.getAttachment(ServletRequestContext.ATTACHMENT_KEY);
        HttpServletRequest req = (HttpServletRequest) servletRequestContext.getServletRequest();
        HttpServletResponse resp = (HttpServletResponse) servletRequestContext.getServletResponse();
        HttpSession session = req.getSession(false);
        if(session != null) {
            String path = (String) session.getAttribute(SESSION_KEY);
            if(path != null) {
                try {
View Full Code Here


                instance = endpointFactory.createInstance();
            } else {
                instance = new ImmediateInstanceHandle<Endpoint>((Endpoint) config.getEndpointConfiguration().getConfigurator().getEndpointInstance(config.getEndpointConfiguration().getEndpointClass()));
            }

            ServletRequestContext src = exchange.getAttachment(ServletRequestContext.ATTACHMENT_KEY);
            Principal principal;
            if(src.getServletRequest() instanceof HttpServletRequest) {
                principal = ((HttpServletRequest)src.getServletRequest()).getUserPrincipal();
            } else {
                principal = src.getOriginalRequest().getUserPrincipal();
            }

            UndertowSession session = new UndertowSession(channel, URI.create(exchange.getRequestURI()), exchange.getAttachment(HandshakeUtil.PATH_PARAMS), exchange.getRequestParameters(), this, principal, instance, config.getEndpointConfiguration(), exchange.getQueryString(), config.getEncodingFactory().createEncoding(config.getEndpointConfiguration()), config.getOpenSessions(), channel.getSubProtocol(), Collections.<Extension>emptyList());
            config.getOpenSessions().add(session);
            session.setMaxBinaryMessageBufferSize(getContainer().getDefaultMaxBinaryMessageBufferSize());
View Full Code Here

    }

    @Override
    public String readAttribute(final HttpServerExchange exchange) {
        ServletRequestContext src = exchange.getAttachment(ServletRequestContext.ATTACHMENT_KEY);
        if(src == null) {
            return RequestURLAttribute.INSTANCE.readAttribute(exchange);
        }
        String path = (String) src.getServletRequest().getAttribute(RequestDispatcher.FORWARD_PATH_INFO);
        String sp = (String) src.getServletRequest().getAttribute(RequestDispatcher.FORWARD_SERVLET_PATH);
        if(path == null && sp == null) {
            return RequestURLAttribute.INSTANCE.readAttribute(exchange);
        }
        if(sp == null) {
            return path;
View Full Code Here

        this.attributeName = attributeName;
    }

    @Override
    public String readAttribute(final HttpServerExchange exchange) {
        ServletRequestContext context = exchange.getAttachment(ServletRequestContext.ATTACHMENT_KEY);
        if (context != null) {
            Object result = context.getServletRequest().getAttribute(attributeName);
            if (result != null) {
                return result.toString();
            }
        }
        return null;
View Full Code Here

        return null;
    }

    @Override
    public void writeAttribute(final HttpServerExchange exchange, final String newValue) throws ReadOnlyAttributeException {
        ServletRequestContext context = exchange.getAttachment(ServletRequestContext.ATTACHMENT_KEY);
        if (context != null) {
            context.getServletRequest().setAttribute(attributeName, newValue);
        }
    }
View Full Code Here

    public static final ServletSessionIdAttribute INSTANCE = new ServletSessionIdAttribute();

    @Override
    public String readAttribute(final HttpServerExchange exchange) {
        ServletRequestContext context = exchange.getAttachment(ServletRequestContext.ATTACHMENT_KEY);
        if (context != null) {
            ServletRequest req = context.getServletRequest();
            if (req instanceof HttpServletRequest) {
                HttpSession session = ((HttpServletRequest) req).getSession(false);
                if (session != null) {
                    return session.getId();
                }
View Full Code Here

        }
        resetBuffer();
        writer = null;
        responseState = ResponseState.NONE;
        exchange.setResponseCode(sc);
        ServletRequestContext src = exchange.getAttachment(ServletRequestContext.ATTACHMENT_KEY);
        if(src.isRunningInsideHandler()) {
            //all we do is set the error on the context, we handle it when the request is returned
            src.setError(sc, msg);
        } else {
            //if the src is null there is no outer handler, as we are in an asnc request
            doErrorDispatch(sc, msg);
        }
    }
View Full Code Here

    public void doErrorDispatch(int sc, String error) throws IOException {
        final String location = servletContext.getDeployment().getErrorPages().getErrorLocation(sc);
        if (location != null) {
            RequestDispatcherImpl requestDispatcher = new RequestDispatcherImpl(location, servletContext);
            final ServletRequestContext servletRequestContext = exchange.getAttachment(ServletRequestContext.ATTACHMENT_KEY);
            try {
                requestDispatcher.error(servletRequestContext, servletRequestContext.getServletRequest(), servletRequestContext.getServletResponse(), exchange.getAttachment(ServletRequestContext.ATTACHMENT_KEY).getCurrentServlet().getManagedServlet().getServletInfo().getName(), error);
            } catch (ServletException e) {
                throw new RuntimeException(e);
            }
        } else if (error != null) {
            setContentType("text/html");
View Full Code Here

    }

    @Override
    public String readAttribute(final HttpServerExchange exchange) {
        ServletRequestContext src = exchange.getAttachment(ServletRequestContext.ATTACHMENT_KEY);
        if(src == null) {
            return RequestURLAttribute.INSTANCE.readAttribute(exchange);
        }
        String uri = (String) src.getServletRequest().getAttribute(RequestDispatcher.FORWARD_REQUEST_URI);
        if(uri == null) {
            return RequestURLAttribute.INSTANCE.readAttribute(exchange);
        }
        return uri;
    }
View Full Code Here

        this.attributeName = attributeName;
    }

    @Override
    public String readAttribute(final HttpServerExchange exchange) {
        ServletRequestContext context = exchange.getAttachment(ServletRequestContext.ATTACHMENT_KEY);
        if (context != null) {
            ServletRequest req = context.getServletRequest();
            if (req instanceof HttpServletRequest) {
                HttpSession session = ((HttpServletRequest) req).getSession(false);
                if (session != null) {
                    Object result = session.getAttribute(attributeName);
                    if (result != null) {
View Full Code Here

TOP

Related Classes of io.undertow.servlet.handlers.ServletRequestContext

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.