Java Code Examples for javax.servlet.ServletRequest#equals()

The following examples show how to use javax.servlet.ServletRequest#equals() . 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: ApplicationDispatcher.java    From Tomcat8-Source-Read with MIT License 4 votes vote down vote up
private void checkSameObjects(ServletRequest appRequest,
        ServletResponse appResponse) throws ServletException {
    ServletRequest originalRequest =
        ApplicationFilterChain.getLastServicedRequest();
    ServletResponse originalResponse =
        ApplicationFilterChain.getLastServicedResponse();

    // Some forwards, eg from valves will not set original values
    if (originalRequest == null || originalResponse == null) {
        return;
    }

    boolean same = false;
    ServletRequest dispatchedRequest = appRequest;

    //find the request that was passed into the service method
    while (originalRequest instanceof ServletRequestWrapper &&
            ((ServletRequestWrapper) originalRequest).getRequest()!=null ) {
        originalRequest =
            ((ServletRequestWrapper) originalRequest).getRequest();
    }
    //compare with the dispatched request
    while (!same) {
        if (originalRequest.equals(dispatchedRequest)) {
            same = true;
        }
        if (!same && dispatchedRequest instanceof ServletRequestWrapper) {
            dispatchedRequest =
                ((ServletRequestWrapper) dispatchedRequest).getRequest();
        } else {
            break;
        }
    }
    if (!same) {
        throw new ServletException(sm.getString(
                "applicationDispatcher.specViolation.request"));
    }

    same = false;
    ServletResponse dispatchedResponse = appResponse;

    //find the response that was passed into the service method
    while (originalResponse instanceof ServletResponseWrapper &&
            ((ServletResponseWrapper) originalResponse).getResponse() !=
                null ) {
        originalResponse =
            ((ServletResponseWrapper) originalResponse).getResponse();
    }
    //compare with the dispatched response
    while (!same) {
        if (originalResponse.equals(dispatchedResponse)) {
            same = true;
        }

        if (!same && dispatchedResponse instanceof ServletResponseWrapper) {
            dispatchedResponse =
                ((ServletResponseWrapper) dispatchedResponse).getResponse();
        } else {
            break;
        }
    }

    if (!same) {
        throw new ServletException(sm.getString(
                "applicationDispatcher.specViolation.response"));
    }
}
 
Example 2
Source File: ApplicationDispatcher.java    From Tomcat7.0.67 with Apache License 2.0 4 votes vote down vote up
private void checkSameObjects(ServletRequest appRequest,
        ServletResponse appResponse) throws ServletException {
    ServletRequest originalRequest =
        ApplicationFilterChain.getLastServicedRequest();
    ServletResponse originalResponse =
        ApplicationFilterChain.getLastServicedResponse();
    
    // Some forwards, eg from valves will not set original values 
    if (originalRequest == null || originalResponse == null) {
        return;
    }
    
    boolean same = false;
    ServletRequest dispatchedRequest = appRequest;
    
    //find the request that was passed into the service method
    while (originalRequest instanceof ServletRequestWrapper &&
            ((ServletRequestWrapper) originalRequest).getRequest()!=null ) {
        originalRequest =
            ((ServletRequestWrapper) originalRequest).getRequest();
    }
    //compare with the dispatched request
    while (!same) {
        if (originalRequest.equals(dispatchedRequest)) {
            same = true;
        }
        if (!same && dispatchedRequest instanceof ServletRequestWrapper) {
            dispatchedRequest =
                ((ServletRequestWrapper) dispatchedRequest).getRequest();
        } else {
            break;
        }
    }
    if (!same) {
        throw new ServletException(sm.getString(
                "applicationDispatcher.specViolation.request"));
    }
    
    same = false;
    ServletResponse dispatchedResponse = appResponse;
    
    //find the response that was passed into the service method
    while (originalResponse instanceof ServletResponseWrapper &&
            ((ServletResponseWrapper) originalResponse).getResponse() != 
                null ) {
        originalResponse =
            ((ServletResponseWrapper) originalResponse).getResponse();
    }
    //compare with the dispatched response
    while (!same) {
        if (originalResponse.equals(dispatchedResponse)) {
            same = true;
        }
        
        if (!same && dispatchedResponse instanceof ServletResponseWrapper) {
            dispatchedResponse =
                ((ServletResponseWrapper) dispatchedResponse).getResponse();
        } else {
            break;
        }
    }

    if (!same) {
        throw new ServletException(sm.getString(
                "applicationDispatcher.specViolation.response"));
    }
}
 
Example 3
Source File: ApplicationDispatcher.java    From tomcatsrc with Apache License 2.0 4 votes vote down vote up
private void checkSameObjects(ServletRequest appRequest,
        ServletResponse appResponse) throws ServletException {
    ServletRequest originalRequest =
        ApplicationFilterChain.getLastServicedRequest();
    ServletResponse originalResponse =
        ApplicationFilterChain.getLastServicedResponse();
    
    // Some forwards, eg from valves will not set original values 
    if (originalRequest == null || originalResponse == null) {
        return;
    }
    
    boolean same = false;
    ServletRequest dispatchedRequest = appRequest;
    
    //find the request that was passed into the service method
    while (originalRequest instanceof ServletRequestWrapper &&
            ((ServletRequestWrapper) originalRequest).getRequest()!=null ) {
        originalRequest =
            ((ServletRequestWrapper) originalRequest).getRequest();
    }
    //compare with the dispatched request
    while (!same) {
        if (originalRequest.equals(dispatchedRequest)) {
            same = true;
        }
        if (!same && dispatchedRequest instanceof ServletRequestWrapper) {
            dispatchedRequest =
                ((ServletRequestWrapper) dispatchedRequest).getRequest();
        } else {
            break;
        }
    }
    if (!same) {
        throw new ServletException(sm.getString(
                "applicationDispatcher.specViolation.request"));
    }
    
    same = false;
    ServletResponse dispatchedResponse = appResponse;
    
    //find the response that was passed into the service method
    while (originalResponse instanceof ServletResponseWrapper &&
            ((ServletResponseWrapper) originalResponse).getResponse() != 
                null ) {
        originalResponse =
            ((ServletResponseWrapper) originalResponse).getResponse();
    }
    //compare with the dispatched response
    while (!same) {
        if (originalResponse.equals(dispatchedResponse)) {
            same = true;
        }
        
        if (!same && dispatchedResponse instanceof ServletResponseWrapper) {
            dispatchedResponse =
                ((ServletResponseWrapper) dispatchedResponse).getResponse();
        } else {
            break;
        }
    }

    if (!same) {
        throw new ServletException(sm.getString(
                "applicationDispatcher.specViolation.response"));
    }
}