Java Code Examples for javax.servlet.ServletRequestWrapper#getRequest()
The following examples show how to use
javax.servlet.ServletRequestWrapper#getRequest() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DefaultServletRequestDispatcher.java From piranha with BSD 3-Clause "New" or "Revised" License | 5 votes |
private HttpServletRequest findHttpServletRequestInChain(ServletRequest request) { ServletRequest currentRequest = request; while (currentRequest instanceof ServletRequestWrapper) { ServletRequestWrapper wrapper = (ServletRequestWrapper) currentRequest; currentRequest = wrapper.getRequest(); if (currentRequest instanceof HttpServletRequest) { return (HttpServletRequest) currentRequest; } } return null; }
Example 2
Source File: DefaultAsyncContext.java From piranha with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * Unwrap the servlet request. * * @param <T> the type. * @param request the request to unwrap. * @return the unwrapped request. */ @SuppressWarnings("unchecked") private <T extends ServletRequest> T unwrapFully(ServletRequest request) { ServletRequest currentRequest = request; while (currentRequest instanceof ServletRequestWrapper) { ServletRequestWrapper wrapper = (ServletRequestWrapper) currentRequest; currentRequest = wrapper.getRequest(); } return (T) currentRequest; }
Example 3
Source File: DefaultWebApplicationRequest.java From piranha with BSD 3-Clause "New" or "Revised" License | 5 votes |
public HttpServletRequest unwrap(HttpServletRequest request) { ServletRequest currentRequest = request; while (currentRequest instanceof ServletRequestWrapper) { ServletRequestWrapper wrapper = (ServletRequestWrapper) currentRequest; currentRequest = wrapper.getRequest(); } return (WebApplicationRequest) currentRequest; }
Example 4
Source File: DefaultServletRequestDispatcher.java From piranha with BSD 3-Clause "New" or "Revised" License | 3 votes |
private void asyncNonHttpForward(AsyncNonHttpDispatchWrapper asyncNonHttpDispatchWrapper, ServletResponse servletResponse) throws ServletException, IOException { // A typical chain to arrive here is DefaultAsyncContext#dispatch -> DefaultAsyncDispatcher#dispatch -> forward -> asyncForward -> asyncNonHttpForward ServletRequest asyncStartRequest = asyncNonHttpDispatchWrapper.getRequest(); if (asyncStartRequest instanceof ServletRequestWrapper) { ServletRequestWrapper applicationProvidedWrapper = (ServletRequestWrapper) asyncStartRequest; HttpServletRequest httpServletRequestInChain = findHttpServletRequestInChain(applicationProvidedWrapper); if (httpServletRequestInChain != null) { // We swap our asyncHttpDispatchWrapper from being the head of the chain, with a new wrapper, wrapping the HttpServletRequest that we found, and put // that in between the request that was provided by the application and the request it is wrapping. ServletRequest wrappedRequest = applicationProvidedWrapper.getRequest(); AsyncHttpDispatchWrapper newAsyncHttpDispatchWrapper = new AsyncHttpDispatchWrapper(null); // Note that by doing this, methods called on HttpServletRequestWrapper itself (and not its super interface) will throw. newAsyncHttpDispatchWrapper.setRequest(wrappedRequest); applicationProvidedWrapper.setRequest(newAsyncHttpDispatchWrapper); // Original chain: asyncNonHttpDispatchWrapper -> applicationProvidedWrapper (asyncStartRequest) -> wrappedRequest -> .... -> HttpServletRequest // New chain: applicationProvidedWrapper (asyncStartRequest) -> newAsyncHttpDispatchWrapper -> wrappedRequest -> .... -> HttpServletRequest invokeTargetAsyncServlet(asyncStartRequest, httpServletRequestInChain, newAsyncHttpDispatchWrapper, servletResponse); } } }