Example usage for javax.servlet.http HttpServletRequest equals

List of usage examples for javax.servlet.http HttpServletRequest equals

Introduction

In this page you can find the example usage for javax.servlet.http HttpServletRequest equals.

Prototype

public boolean equals(Object obj) 

Source Link

Document

Indicates whether some other object is "equal to" this one.

Usage

From source file:com.google.code.rees.scope.spring.SpringConversationAdapter.java

/**
 * {@inheritDoc}/*from w  ww .  j av a  2  s. co m*/
 */
@Override
public Map<String, String> getRequestContext() {

    HttpServletRequest currentRequest = ((ServletRequestAttributes) RequestContextHolder
            .currentRequestAttributes()).getRequest();

    if (!currentRequest.equals(this.request)) {
        this.request = currentRequest;
        requestContext = RequestContextUtil.getRequestContext(currentRequest);
    }

    return this.requestContext;
}

From source file:org.eclipse.equinox.http.servlet.tests.ServletTest.java

public void basicFilterTest22(String servlet1Pattern, String servlet2Pattern, String filterPattern,
        String expected, String[] dispatchers) throws Exception {
    final AtomicReference<HttpServletRequestWrapper> httpServletRequestWrapper = new AtomicReference<HttpServletRequestWrapper>();
    final AtomicReference<HttpServletResponseWrapper> httpServletResponseWrapper = new AtomicReference<HttpServletResponseWrapper>();

    Servlet servlet1 = new BaseServlet() {
        private static final long serialVersionUID = 1L;

        @Override//from   w  w  w. j  a v  a2 s .c  o  m
        protected void service(HttpServletRequest request, HttpServletResponse response)
                throws ServletException, IOException {
            request.getRequestDispatcher("index.jsp").forward(request, response);
        }
    };

    Servlet servlet2 = new BaseServlet("a") {
        private static final long serialVersionUID = 1L;

        @Override
        protected void service(HttpServletRequest request, HttpServletResponse response)
                throws ServletException, IOException {

            if ((httpServletRequestWrapper.get() != null) && !request.equals(httpServletRequestWrapper.get())) {
                throw new ServletException("not the same request");
            }
            if ((httpServletResponseWrapper.get() != null)
                    && !response.equals(httpServletResponseWrapper.get())) {
                throw new ServletException("not the same response");
            }

            response.getWriter().print(content);
        }

    };

    Filter filter = new TestFilter() {

        @Override
        public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
                throws IOException, ServletException {

            response.getWriter().write('b');

            httpServletRequestWrapper.set(new HttpServletRequestWrapper((HttpServletRequest) request));
            httpServletResponseWrapper.set(new HttpServletResponseWrapper((HttpServletResponse) response));

            chain.doFilter(httpServletRequestWrapper.get(), httpServletResponseWrapper.get());

            response.getWriter().write('b');
        }

    };

    Dictionary<String, Object> props = new Hashtable<String, Object>();
    props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_PATTERN, servlet1Pattern);
    registrations.add(getBundleContext().registerService(Servlet.class, servlet1, props));

    props = new Hashtable<String, Object>();
    props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_SERVLET_PATTERN, servlet2Pattern);
    registrations.add(getBundleContext().registerService(Servlet.class, servlet2, props));

    props = new Hashtable<String, Object>();
    props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_FILTER_NAME, "F22");
    props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_FILTER_DISPATCHER, dispatchers);
    props.put(HttpWhiteboardConstants.HTTP_WHITEBOARD_FILTER_PATTERN, filterPattern);
    registrations.add(getBundleContext().registerService(Filter.class, filter, props));

    String response = requestAdvisor.request("f22/a");

    Assert.assertEquals(expected, response);
}