当前位置: 首页>>代码示例>>Java>>正文


Java ServletResponseWrapper类代码示例

本文整理汇总了Java中javax.servlet.ServletResponseWrapper的典型用法代码示例。如果您正苦于以下问题:Java ServletResponseWrapper类的具体用法?Java ServletResponseWrapper怎么用?Java ServletResponseWrapper使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


ServletResponseWrapper类属于javax.servlet包,在下文中一共展示了ServletResponseWrapper类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: startAsync

import javax.servlet.ServletResponseWrapper; //导入依赖的package包/类
@Override
public AsyncContext startAsync(final ServletRequest servletRequest, final ServletResponse servletResponse) throws IllegalStateException {
    final ServletRequestContext servletRequestContext = exchange.getAttachment(ServletRequestContext.ATTACHMENT_KEY);
    if (!servletContext.getDeployment().getDeploymentInfo().isAllowNonStandardWrappers()) {
        if (servletRequestContext.getOriginalRequest() != servletRequest) {
            if (!(servletRequest instanceof ServletRequestWrapper)) {
                throw UndertowServletMessages.MESSAGES.requestWasNotOriginalOrWrapper(servletRequest);
            }
        }
        if (servletRequestContext.getOriginalResponse() != servletResponse) {
            if (!(servletResponse instanceof ServletResponseWrapper)) {
                throw UndertowServletMessages.MESSAGES.responseWasNotOriginalOrWrapper(servletResponse);
            }
        }
    }
    if (!isAsyncSupported()) {
        throw UndertowServletMessages.MESSAGES.startAsyncNotAllowed();
    } else if (asyncStarted) {
        throw UndertowServletMessages.MESSAGES.asyncAlreadyStarted();
    }
    asyncStarted = true;
    return asyncContext = new AsyncContextImpl(exchange, servletRequest, servletResponse, servletRequestContext, true, asyncContext);
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:24,代码来源:HttpServletRequestImpl.java

示例2: getServletOutputStream

import javax.servlet.ServletResponseWrapper; //导入依赖的package包/类
protected ServletOutputStream getServletOutputStream(HttpServletResponse response)
        throws IOException {
    ServletOutputStream o;
    if (response instanceof ServletResponseWrapper) {
        log.warn("Response is instance of ServletResponseWrapper");
        o = response.getOutputStream();
        /*
        HttpServletResponse rawResponse =
            (HttpServletResponse) ((ServletResponseWrapper) response).getResponse();
        o = rawResponse.getOutputStream();
        */
    } else {
        log.warn("Response is instance of ServletResponse");
        o = response.getOutputStream();
    }

    return o;
}
 
开发者ID:otsecbsol,项目名称:linkbinder,代码行数:19,代码来源:ViewHelper.java

示例3: expireAuthenticationCookieForExpiredAuthToken

import javax.servlet.ServletResponseWrapper; //导入依赖的package包/类
@Test
public void expireAuthenticationCookieForExpiredAuthToken() throws Exception {
    CookieSecurityContextRepository repository = createCookieSecurityContextRepository();
    MockHttpServletRequest request = new MockHttpServletRequest();
    request.setSecure(true);
    request.setCookies(new Cookie(AUTHENTICATION_COOKIE_NAME, "eyJjdHkiOiJKV1QiLCJlbmMiOiJBMjU2R0NNIiwiYWxnIjoiZGlyIn0..v3OyQykgTQI5U7gP.dKsmMKX1MHGoMx2rXrCCWOCbyax-J8JS6gu63OBXEDm7Ab926OwlwlZcvoOZGW5nO7ZR95h2pe8pQs8s8cqWJUO4L4dGI9jTj4jK_Lsy9cPWDY4BMzs2bVBuasn88OQYjC-3zuZyvPKfQHrSVS9OjTaMLeMBwMfKP-k3IysOUfUtWUNcRb86v7VCnOd0ATljXUN8DekK8iZ0wD5AtBJVaOQLbaNWiXGY2pnA2eOW9cI_vPbCqqn4ZW-r7sEy6UzHgXYgRAr4bKb7abVtRvO1Xg3CcpquE597Om0bKJIk-VVCz7fVzpz5rkp16vzN-RKBJBs2MK-UsXKD9Lkgedh5w--Q4muiWrAqA5_Tx36mvkESlzR5pbsKu84ZweE5dfen47q_BWaZguVb8jFJB1pofpEgNiZ1C1K8aKIO03CIR-cOOfvoPrsdte-0M4F5bq4KwLna8fYm9D3OeJN3sai3Ba2KKPtLsfz-F5jJlCOV44JE-F9Pqa1xfdpD_S5UenWFi9IUsM912BoCTX4ouEMP6ZUVHwKgTeFjInJXe6iJVqvhPfrWUeVUBmBURy_8XGrzW12GqN_Qp_-275gQ_jlQfyMsdtkLdMp9YxpIbPb4Whq0ey5eKvy924Z4aWKQcw6SrVPAhFjXbvtwGVJYv2lzQ2vQIDE9g1dxqPpRvAG_qb_4M3Xfhtjo2W1Md-U1Oo5cfDsrbqeeegeYDH_AA5t5tJxLDB7TtR8xtjFb52WNItxcKeMnb6jegAwWlEjAkAqY.1d7Z0BNKOegXeUI_fY8yQg"));
    MockHttpServletResponse response = new MockHttpServletResponse();
    HttpRequestResponseHolder requestResponseHolder = new HttpRequestResponseHolder(request, response);

    repository.loadContext(requestResponseHolder);

    ServletResponseWrapper responseWrapper = (ServletResponseWrapper) requestResponseHolder.getResponse();
    MockHttpServletResponse wrappedResponse = (MockHttpServletResponse) responseWrapper.getResponse();
    Cookie authenticationCookie = wrappedResponse.getCookie(AUTHENTICATION_COOKIE_NAME);
    assertThat(authenticationCookie.getMaxAge(), equalTo(0));
    assertThat(authenticationCookie.getValue(), isEmptyString());
    assertTrue(authenticationCookie.getSecure());
    assertTrue(authenticationCookie.isHttpOnly());
}
 
开发者ID:AusDTO,项目名称:spring-security-stateless,代码行数:20,代码来源:CookieSecurityContextRepositoryTest.java

示例4: expireSessionCookieForExpiredAuthToken

import javax.servlet.ServletResponseWrapper; //导入依赖的package包/类
@Test
public void expireSessionCookieForExpiredAuthToken() throws Exception {
    CookieBasedSecurityContextRepository repository = createCookieBasedSecurityContextRepository();
    MockHttpServletRequest request = new MockHttpServletRequest();
    request.setSecure(true);
    request.setCookies(new Cookie(SecurityContextSerializer.COOKIE_NAME, "eyJjdHkiOiJKV1QiLCJlbmMiOiJBMjU2R0NNIiwiYWxnIjoiZGlyIn0..v3OyQykgTQI5U7gP.dKsmMKX1MHGoMx2rXrCCWOCbyax-J8JS6gu63OBXEDm7Ab926OwlwlZcvoOZGW5nO7ZR95h2pe8pQs8s8cqWJUO4L4dGI9jTj4jK_Lsy9cPWDY4BMzs2bVBuasn88OQYjC-3zuZyvPKfQHrSVS9OjTaMLeMBwMfKP-k3IysOUfUtWUNcRb86v7VCnOd0ATljXUN8DekK8iZ0wD5AtBJVaOQLbaNWiXGY2pnA2eOW9cI_vPbCqqn4ZW-r7sEy6UzHgXYgRAr4bKb7abVtRvO1Xg3CcpquE597Om0bKJIk-VVCz7fVzpz5rkp16vzN-RKBJBs2MK-UsXKD9Lkgedh5w--Q4muiWrAqA5_Tx36mvkESlzR5pbsKu84ZweE5dfen47q_BWaZguVb8jFJB1pofpEgNiZ1C1K8aKIO03CIR-cOOfvoPrsdte-0M4F5bq4KwLna8fYm9D3OeJN3sai3Ba2KKPtLsfz-F5jJlCOV44JE-F9Pqa1xfdpD_S5UenWFi9IUsM912BoCTX4ouEMP6ZUVHwKgTeFjInJXe6iJVqvhPfrWUeVUBmBURy_8XGrzW12GqN_Qp_-275gQ_jlQfyMsdtkLdMp9YxpIbPb4Whq0ey5eKvy924Z4aWKQcw6SrVPAhFjXbvtwGVJYv2lzQ2vQIDE9g1dxqPpRvAG_qb_4M3Xfhtjo2W1Md-U1Oo5cfDsrbqeeegeYDH_AA5t5tJxLDB7TtR8xtjFb52WNItxcKeMnb6jegAwWlEjAkAqY.1d7Z0BNKOegXeUI_fY8yQg"));
    MockHttpServletResponse response = new MockHttpServletResponse();
    HttpRequestResponseHolder requestResponseHolder = new HttpRequestResponseHolder(request, response);

    repository.loadContext(requestResponseHolder);

    ServletResponseWrapper responseWrapper = (ServletResponseWrapper) requestResponseHolder.getResponse();
    MockHttpServletResponse wrappedResponse = (MockHttpServletResponse) responseWrapper.getResponse();
    Cookie sessionCookie = wrappedResponse.getCookie(SecurityContextSerializer.COOKIE_NAME);
    assertThat(sessionCookie.getMaxAge(), equalTo(0));
    assertThat(sessionCookie.getValue(), isEmptyString());
    assertTrue(sessionCookie.getSecure());
    assertTrue(sessionCookie.isHttpOnly());
}
 
开发者ID:AusDTO,项目名称:citizenship-appointment-server,代码行数:20,代码来源:CookieBasedSecurityContextRepositoryTest.java

示例5: unwrapResponse

import javax.servlet.ServletResponseWrapper; //导入依赖的package包/类
/**
 * Unwrap the response if we have wrapped it.
 */
private void unwrapResponse(State state) {

    if (state.wrapResponse == null)
        return;

    if (state.outerRequest.isAsyncStarted()) {
        if (!state.outerRequest.getAsyncContext().hasOriginalRequestAndResponse()) {
            return;
        }
    }

    ServletResponse previous = null;
    ServletResponse current = state.outerResponse;
    while (current != null) {

        // If we run into the container response we are done
        if ((current instanceof Response)
            || (current instanceof ResponseFacade))
            break;

        // Remove the current response if it is our wrapper
        if (current == state.wrapResponse) {
            ServletResponse next =
              ((ServletResponseWrapper) current).getResponse();
            if (previous == null)
                state.outerResponse = next;
            else
                ((ServletResponseWrapper) previous).setResponse(next);
            break;
        }

        // Advance to the next response in the chain
        previous = current;
        current = ((ServletResponseWrapper) current).getResponse();

    }

}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:42,代码来源:ApplicationDispatcher.java

示例6: wrapResponse

import javax.servlet.ServletResponseWrapper; //导入依赖的package包/类
/**
 * Create and return a response wrapper that has been inserted in the
 * appropriate spot in the response chain.
 */
private ServletResponse wrapResponse(State state) {

    // Locate the response we should insert in front of
    ServletResponse previous = null;
    ServletResponse current = state.outerResponse;
    while (current != null) {
        if(state.hresponse == null && (current instanceof HttpServletResponse)) {
            state.hresponse = (HttpServletResponse)current;
            if(!state.including) // Forward only needs hresponse
                return null;
        }
        if (!(current instanceof ServletResponseWrapper))
            break;
        if (current instanceof ApplicationHttpResponse)
            break;
        if (current instanceof ApplicationResponse)
            break;
        previous = current;
        current = ((ServletResponseWrapper) current).getResponse();
    }

    // Instantiate a new wrapper at this point and insert it in the chain
    ServletResponse wrapper = null;
    if ((current instanceof ApplicationHttpResponse) ||
        (current instanceof Response) ||
        (current instanceof HttpServletResponse))
        wrapper =
            new ApplicationHttpResponse((HttpServletResponse) current,
                    state.including);
    else
        wrapper = new ApplicationResponse(current, state.including);
    if (previous == null)
        state.outerResponse = wrapper;
    else
        ((ServletResponseWrapper) previous).setResponse(wrapper);
    state.wrapResponse = wrapper;
    return (wrapper);

}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:44,代码来源:ApplicationDispatcher.java

示例7: service

import javax.servlet.ServletResponseWrapper; //导入依赖的package包/类
@Override
public void service(ServletRequest req, ServletResponse resp)
        throws ServletException, IOException {
    if (DispatcherType.ASYNC != req.getDispatcherType()) {
        AsyncContext asyncContext;
        if ("y".equals(req.getParameter(CUSTOM_REQ_RESP))) {
            asyncContext = req.startAsync(
                    new ServletRequestWrapper(req),
                    new ServletResponseWrapper(resp));
        } else {
            asyncContext = req.startAsync();
        }
        if ("y".equals(req.getParameter(EMPTY_DISPATCH))) {
            asyncContext.dispatch();
        } else {
            asyncContext.dispatch("/target");
        }
        try {
            asyncContext.dispatch("/nonExistingServlet");
            TestAsyncContextImpl.track("FAIL");
        } catch (IllegalStateException e) {
            TestAsyncContextImpl.track("OK");
        }
    } else {
        TestAsyncContextImpl.track("DispatchingGenericServletGet-");
    }
}
 
开发者ID:liaokailin,项目名称:tomcat7,代码行数:28,代码来源:TestAsyncContextImpl.java

示例8: getNativeResponse

import javax.servlet.ServletResponseWrapper; //导入依赖的package包/类
/**
 * Return an appropriate response object of the specified type, if available,
 * unwrapping the given response as far as necessary.
 * @param response the servlet response to introspect
 * @param requiredType the desired type of response object
 * @return the matching response object, or {@code null} if none
 * of that type is available
 */
@SuppressWarnings("unchecked")
public static <T> T getNativeResponse(ServletResponse response, Class<T> requiredType) {
	if (requiredType != null) {
		if (requiredType.isInstance(response)) {
			return (T) response;
		}
		else if (response instanceof ServletResponseWrapper) {
			return getNativeResponse(((ServletResponseWrapper) response).getResponse(), requiredType);
		}
	}
	return null;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:21,代码来源:WebUtils.java

示例9: unwrapResponse

import javax.servlet.ServletResponseWrapper; //导入依赖的package包/类
/**
 * Unwrap the response if we have wrapped it.
 */
private void unwrapResponse(State state) {

    if (state.wrapResponse == null)
        return;

    ServletResponse previous = null;
    ServletResponse current = state.outerResponse;
    while (current != null) {

        // If we run into the container response we are done
        if ((current instanceof Response)
            || (current instanceof ResponseFacade))
            break;

        // Remove the current response if it is our wrapper
        if (current == state.wrapResponse) {
            ServletResponse next =
              ((ServletResponseWrapper) current).getResponse();
            if (previous == null)
                state.outerResponse = next;
            else
                ((ServletResponseWrapper) previous).setResponse(next);
            break;
        }

        // Advance to the next response in the chain
        previous = current;
        current = ((ServletResponseWrapper) current).getResponse();

    }

}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:36,代码来源:ApplicationDispatcher.java

示例10: unwrapResponse

import javax.servlet.ServletResponseWrapper; //导入依赖的package包/类
/**
 * Unwrap the response if we have wrapped it.
 */
private void unwrapResponse() {

    if (wrapResponse == null)
        return;

    ServletResponse previous = null;
    ServletResponse current = outerResponse;
    while (current != null) {

        // If we run into the container response we are done
        if ((current instanceof Response) 
            || (current instanceof ResponseFacade))
            break;

        // Remove the current response if it is our wrapper
        if (current == wrapResponse) {
            ServletResponse next =
              ((ServletResponseWrapper) current).getResponse();
            if (previous == null)
                outerResponse = next;
            else
                ((ServletResponseWrapper) previous).setResponse(next);
            break;
        }

        // Advance to the next response in the chain
        previous = current;
        current = ((ServletResponseWrapper) current).getResponse();

    }

}
 
开发者ID:c-rainstorm,项目名称:jerrydog,代码行数:36,代码来源:ApplicationDispatcher.java

示例11: wrapResponse

import javax.servlet.ServletResponseWrapper; //导入依赖的package包/类
/**
 * Create and return a response wrapper that has been inserted in the
 * appropriate spot in the response chain.
 */
private ServletResponse wrapResponse() {

    // Locate the response we should insert in front of
    ServletResponse previous = null;
    ServletResponse current = outerResponse;
    while (current != null) {
        if (!(current instanceof ServletResponseWrapper))
            break;
        if (current instanceof ApplicationHttpResponse)
            break;
        if (current instanceof ApplicationResponse)
            break;
        if (current instanceof Response)
            break;
        previous = current;
        current = ((ServletResponseWrapper) current).getResponse();
    }

    // Instantiate a new wrapper at this point and insert it in the chain
    ServletResponse wrapper = null;
    if ((current instanceof ApplicationHttpResponse) ||
        (current instanceof HttpResponse) ||
        (current instanceof HttpServletResponse))
        wrapper =
            new ApplicationHttpResponse((HttpServletResponse) current,
                                        including);
    else
        wrapper = new ApplicationResponse(current, including);
    if (previous == null)
        outerResponse = wrapper;
    else
        ((ServletResponseWrapper) previous).setResponse(wrapper);
    wrapResponse = wrapper;
    return (wrapper);

}
 
开发者ID:c-rainstorm,项目名称:jerrydog,代码行数:41,代码来源:ApplicationDispatcher.java

示例12: unwrapResponse

import javax.servlet.ServletResponseWrapper; //导入依赖的package包/类
/**
 * Unwrap the response if we have wrapped it.
 */
private void unwrapResponse(State state) {

	if (state.wrapResponse == null)
		return;

	if (state.outerRequest.isAsyncStarted()) {
		if (!state.outerRequest.getAsyncContext().hasOriginalRequestAndResponse()) {
			return;
		}
	}

	ServletResponse previous = null;
	ServletResponse current = state.outerResponse;
	while (current != null) {

		// If we run into the container response we are done
		if ((current instanceof Response) || (current instanceof ResponseFacade))
			break;

		// Remove the current response if it is our wrapper
		if (current == state.wrapResponse) {
			ServletResponse next = ((ServletResponseWrapper) current).getResponse();
			if (previous == null)
				state.outerResponse = next;
			else
				((ServletResponseWrapper) previous).setResponse(next);
			break;
		}

		// Advance to the next response in the chain
		previous = current;
		current = ((ServletResponseWrapper) current).getResponse();

	}

}
 
开发者ID:how2j,项目名称:lazycat,代码行数:40,代码来源:ApplicationDispatcher.java

示例13: wrapResponse

import javax.servlet.ServletResponseWrapper; //导入依赖的package包/类
/**
 * Create and return a response wrapper that has been inserted in the
 * appropriate spot in the response chain.
 */
private ServletResponse wrapResponse(State state) {

	// Locate the response we should insert in front of
	ServletResponse previous = null;
	ServletResponse current = state.outerResponse;
	while (current != null) {
		if (state.hresponse == null && (current instanceof HttpServletResponse)) {
			state.hresponse = (HttpServletResponse) current;
			if (!state.including) // Forward only needs hresponse
				return null;
		}
		if (!(current instanceof ServletResponseWrapper))
			break;
		if (current instanceof ApplicationHttpResponse)
			break;
		if (current instanceof ApplicationResponse)
			break;
		previous = current;
		current = ((ServletResponseWrapper) current).getResponse();
	}

	// Instantiate a new wrapper at this point and insert it in the chain
	ServletResponse wrapper = null;
	if ((current instanceof ApplicationHttpResponse) || (current instanceof Response)
			|| (current instanceof HttpServletResponse))
		wrapper = new ApplicationHttpResponse((HttpServletResponse) current, state.including);
	else
		wrapper = new ApplicationResponse(current, state.including);
	if (previous == null)
		state.outerResponse = wrapper;
	else
		((ServletResponseWrapper) previous).setResponse(wrapper);
	state.wrapResponse = wrapper;
	return (wrapper);

}
 
开发者ID:how2j,项目名称:lazycat,代码行数:41,代码来源:ApplicationDispatcher.java

示例14: getUnwrappedResponse

import javax.servlet.ServletResponseWrapper; //导入依赖的package包/类
/**
 * Unwrap back to the original container allocated response object
 */
protected WinstoneResponse getUnwrappedResponse(final ServletResponse response) {
	ServletResponse workingResponse = response;
	while (workingResponse instanceof ServletResponseWrapper) {
		workingResponse = ((ServletResponseWrapper) workingResponse).getResponse();
	}
	return (WinstoneResponse) workingResponse;
}
 
开发者ID:geronimo-iia,项目名称:winstone,代码行数:11,代码来源:SimpleRequestDispatcher.java

示例15: getUnwrappedResponse

import javax.servlet.ServletResponseWrapper; //导入依赖的package包/类
protected HttpServletResponse getUnwrappedResponse() {
	ServletResponse result = response;
	while (result instanceof ServletResponseWrapper) {
		result = ((ServletResponseWrapper) result).getResponse();
	}
	return (HttpServletResponse) result;
}
 
开发者ID:rzschech,项目名称:gwt-comet,代码行数:8,代码来源:CometServletResponseImpl.java


注:本文中的javax.servlet.ServletResponseWrapper类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。