Package javax.servlet

Examples of javax.servlet.ServletResponse


        }

        // Check to see if a Filter, Valve of wrapper has written some content.
        // If it has, disable range requests and setting of a content length
        // since neither can be done reliably.
        ServletResponse r = response;
        long contentWritten = 0;
        while (r instanceof ServletResponseWrapper) {
            r = ((ServletResponseWrapper) r).getResponse();
        }
        if (r instanceof ResponseFacade) {
View Full Code Here


            }
            return lastRequest;
        }

        static ServletResponse unwrapServletResponse(ServletResponse response) {
            ServletResponse lastResponse = response;
            while (response != null) {
                if (response instanceof SlingHttpServletResponseImpl) {
                    return ((SlingHttpServletResponseImpl) response).getResponse();
                } else if (response instanceof ServletResponseWrapper) {
                    lastResponse = response;
View Full Code Here

    /**
     * Unwrapping a non-wrapper response should return the response itself.
     */
    @Test
    public void testUnwrappingRegularResponse() {
        final ServletResponse req = context.mock(ServletResponse.class);
       
        ServletResponse unwrapped = ExternalServletContextWrapper.
            RequestDispatcherWrapper.unwrapServletResponse(req);
       
        assertEquals(req, unwrapped);
    }
View Full Code Here

    /**
     * Unwrapping a wrapper response should return in the response.
     */
    @Test
    public void testUnwrappingWrappedResponse() {
        final ServletResponse resp = context.mock(ServletResponse.class);
        final ServletResponseWrapper wrapper = new ServletResponseWrapper(resp);
       
        ServletResponse unwrapped = ExternalServletContextWrapper.
            RequestDispatcherWrapper.unwrapServletResponse(wrapper);
       
        assertEquals(resp, unwrapped);
    }
View Full Code Here

        assertEquals(resp, unwrapped);
    }
   
    @Test
    public void testUnwrappingDoubleWrappedResponse() {
        final ServletResponse resp = context.mock(ServletResponse.class);
        final ServletResponseWrapper wrapper = new ServletResponseWrapper(resp);
        final ServletResponseWrapper wrapper2 = new ServletResponseWrapper(wrapper);
       
        ServletResponse unwrapped = ExternalServletContextWrapper.
            RequestDispatcherWrapper.unwrapServletResponse(wrapper2);
       
        assertEquals(resp, unwrapped);
    }
View Full Code Here

        final HttpServletResponse resp = context.mock(HttpServletResponse.class);
        final HttpServletResponseWrapper wrapper = new HttpServletResponseWrapper(resp);
        final HttpServletResponseWrapper wrapper2 = new HttpServletResponseWrapper(wrapper);
        final SlingHttpServletResponseImpl slingResponse = new SlingHttpServletResponseImpl(null, wrapper2);
       
        ServletResponse unwrapped = ExternalServletContextWrapper.
            RequestDispatcherWrapper.unwrapServletResponse(slingResponse);
       
        assertEquals(wrapper2, unwrapped);
    }
View Full Code Here

        final HttpServletResponseWrapper wrapper = new HttpServletResponseWrapper(resp);
        final HttpServletResponseWrapper wrapper2 = new HttpServletResponseWrapper(wrapper);
        final SlingHttpServletResponseImpl slingResponse = new SlingHttpServletResponseImpl(null, wrapper2);
        final HttpServletResponseWrapper slingWrapper = new HttpServletResponseWrapper(slingResponse);
       
        ServletResponse unwrapped = ExternalServletContextWrapper.
            RequestDispatcherWrapper.unwrapServletResponse(slingWrapper);
       
        assertEquals(wrapper2, unwrapped);
    }
View Full Code Here

      return xmlSourceFile;
   
    // The source is dynamically generated
    RequestDispatcher dispatcher = request.getRequestDispatcher(xmlPath);
    SlingGeneratorServletOutputStream output = new SlingGeneratorServletOutputStream();
    ServletResponse newResponse = new SlingGeneratorServletResponse(response, output);
    dispatcher.include(request, newResponse);
    byte[] bytes = output.toByteArray();
    if (bytes.length > 0)
      return new ByteArrayInputStream(bytes);
   
View Full Code Here

    }

    @Override
    public int doEndTag() throws JspException {
        final ServletRequest request = pageContext.getRequest();
        final ServletResponse response = pageContext.getResponse();
        // get the current feed
        Feed feed = getFeed(request);

        // we need tags for that
        /*
         * feed.addEntry(null);
         */

        // write the feed
        try {
            response.setContentType("application/atom+xml");

            ClassLoader classLoader = Thread.currentThread().getContextClassLoader();
            Thread.currentThread().setContextClassLoader(
                getClass().getClassLoader());
            try {
                feed.writeTo(response.getOutputStream());
            } finally {
                Thread.currentThread().setContextClassLoader(classLoader);
            }
        } catch (IOException e) {
            throw new JspException("Unable to write feed", e);
View Full Code Here

    HttpServletRequest request = Mockito.mock(HttpServletRequest.class);
    Mockito.when(request.getUserPrincipal()).thenReturn(null);
    Mockito.when(request.getMethod()).thenReturn("METHOD");
    Mockito.when(request.getPathInfo()).thenReturn("/pathinfo");

    ServletResponse response = Mockito.mock(ServletResponse.class);

    final AtomicBoolean invoked = new AtomicBoolean();

    FilterChain chain = new FilterChain() {
      @Override
View Full Code Here

TOP

Related Classes of javax.servlet.ServletResponse

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.