|
|||||||||||||||||||
| 30 day Evaluation Version distributed via the Maven Jar Repository. Clover is not free. You have 30 days to evaluate it. Please visit http://www.thecortex.net/clover to obtain a licensed version of Clover | |||||||||||||||||||
| Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
| RequestDispatcherWrapper.java | 50% | 77.8% | 100% | 75% |
|
||||||||||||||
| 1 |
/*
|
|
| 2 |
* ========================================================================
|
|
| 3 |
*
|
|
| 4 |
* Copyright 2001-2004 The Apache Software Foundation.
|
|
| 5 |
*
|
|
| 6 |
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
| 7 |
* you may not use this file except in compliance with the License.
|
|
| 8 |
* You may obtain a copy of the License at
|
|
| 9 |
*
|
|
| 10 |
* http://www.apache.org/licenses/LICENSE-2.0
|
|
| 11 |
*
|
|
| 12 |
* Unless required by applicable law or agreed to in writing, software
|
|
| 13 |
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
| 14 |
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
| 15 |
* See the License for the specific language governing permissions and
|
|
| 16 |
* limitations under the License.
|
|
| 17 |
*
|
|
| 18 |
* ========================================================================
|
|
| 19 |
*/
|
|
| 20 |
package org.apache.cactus.server;
|
|
| 21 |
|
|
| 22 |
import java.io.IOException;
|
|
| 23 |
|
|
| 24 |
import javax.servlet.RequestDispatcher;
|
|
| 25 |
import javax.servlet.ServletException;
|
|
| 26 |
import javax.servlet.ServletRequest;
|
|
| 27 |
import javax.servlet.ServletResponse;
|
|
| 28 |
|
|
| 29 |
/**
|
|
| 30 |
* Wrapper around <code>RequestDispatcher</code> which overrides the
|
|
| 31 |
* <code>forward()</code> and <code>include</code> methods to use the original
|
|
| 32 |
* HTTP request object instead of the simulated one used by Cactus.
|
|
| 33 |
*
|
|
| 34 |
* @version $Id: RequestDispatcherWrapper.java 238991 2004-05-22 11:34:50Z vmassol $
|
|
| 35 |
*/
|
|
| 36 |
public class RequestDispatcherWrapper implements RequestDispatcher |
|
| 37 |
{
|
|
| 38 |
/**
|
|
| 39 |
* The original request dispatcher object
|
|
| 40 |
*/
|
|
| 41 |
private RequestDispatcher originalDispatcher;
|
|
| 42 |
|
|
| 43 |
/**
|
|
| 44 |
* @param theOriginalDispatcher the original request dispatcher object
|
|
| 45 |
*/
|
|
| 46 | 2 |
public RequestDispatcherWrapper(RequestDispatcher theOriginalDispatcher)
|
| 47 |
{
|
|
| 48 | 2 |
this.originalDispatcher = theOriginalDispatcher;
|
| 49 |
} |
|
| 50 |
|
|
| 51 |
/**
|
|
| 52 |
* Call the original <code>RequestDispatcher</code> <code>forward()</code>
|
|
| 53 |
* method but with the original HTTP request (not the simulation one which
|
|
| 54 |
* would make the servlet engine choke !).
|
|
| 55 |
*
|
|
| 56 |
* @param theRequest the simulation HTTP request
|
|
| 57 |
* @param theResponse the original HTTP response
|
|
| 58 |
* @exception IOException {@link RequestDispatcher#forward}
|
|
| 59 |
* @exception ServletException {@link RequestDispatcher#forward}
|
|
| 60 |
*/
|
|
| 61 | 1 |
public void forward(ServletRequest theRequest, ServletResponse theResponse) |
| 62 |
throws IOException, ServletException
|
|
| 63 |
{
|
|
| 64 |
// Always pass the original request to the forward() call.
|
|
| 65 | 1 |
if (HttpServletRequestWrapper.class.isAssignableFrom( |
| 66 |
theRequest.getClass())) |
|
| 67 |
{
|
|
| 68 | 1 |
HttpServletRequestWrapper request = |
| 69 |
(HttpServletRequestWrapper) theRequest; |
|
| 70 |
|
|
| 71 | 1 |
this.originalDispatcher.forward(request.getOriginalRequest(),
|
| 72 |
theResponse); |
|
| 73 |
} |
|
| 74 |
else
|
|
| 75 |
{
|
|
| 76 | 0 |
this.originalDispatcher.forward(theRequest, theResponse);
|
| 77 |
} |
|
| 78 |
} |
|
| 79 |
|
|
| 80 |
/**
|
|
| 81 |
* Call the original <code>RequestDispatcher</code> <code>include()</code>
|
|
| 82 |
* method but with the original HTTP request (not the simulation one which
|
|
| 83 |
* would make the servlet engine choke !).
|
|
| 84 |
*
|
|
| 85 |
* @param theRequest the simulation HTTP request
|
|
| 86 |
* @param theResponse the original HTTP response
|
|
| 87 |
* @exception IOException {@link RequestDispatcher#forward}
|
|
| 88 |
* @exception ServletException {@link RequestDispatcher#forward}
|
|
| 89 |
*/
|
|
| 90 | 1 |
public void include(ServletRequest theRequest, ServletResponse theResponse) |
| 91 |
throws IOException, ServletException
|
|
| 92 |
{
|
|
| 93 |
// Always pass the original request to the forward() call.
|
|
| 94 | 1 |
if (HttpServletRequestWrapper.class.isAssignableFrom( |
| 95 |
theRequest.getClass())) |
|
| 96 |
{
|
|
| 97 | 1 |
HttpServletRequestWrapper request = |
| 98 |
(HttpServletRequestWrapper) theRequest; |
|
| 99 |
|
|
| 100 | 1 |
this.originalDispatcher.include(request.getOriginalRequest(),
|
| 101 |
theResponse); |
|
| 102 |
} |
|
| 103 |
else
|
|
| 104 |
{
|
|
| 105 | 0 |
this.originalDispatcher.include(theRequest, theResponse);
|
| 106 |
} |
|
| 107 |
} |
|
| 108 |
} |
|
| 109 |
|
|
||||||||||