001    /**
002     * Copyright (c) 2000-2012 Liferay, Inc. All rights reserved.
003     *
004     * The contents of this file are subject to the terms of the Liferay Enterprise
005     * Subscription License ("License"). You may not use this file except in
006     * compliance with the License. You can obtain a copy of the License by
007     * contacting Liferay, Inc. See the License for the specific language governing
008     * permissions and limitations under the License, including but not limited to
009     * distribution rights of the Software.
010     *
011     *
012     *
013     */
014    
015    package com.liferay.portal.servlet;
016    
017    import com.liferay.portal.kernel.util.WebKeys;
018    
019    import java.io.IOException;
020    
021    import javax.servlet.RequestDispatcher;
022    import javax.servlet.ServletException;
023    import javax.servlet.ServletRequest;
024    import javax.servlet.ServletResponse;
025    
026    /**
027     * @author Shuyang Zhou
028     */
029    public class DirectServletPathRegisterDispatcher implements RequestDispatcher {
030    
031            public DirectServletPathRegisterDispatcher(
032                    String path, RequestDispatcher requestDispatcher) {
033    
034                    _path = path;
035                    _requestDispatcher = requestDispatcher;
036            }
037    
038            public void forward(
039                            ServletRequest servletRequest, ServletResponse servletResponse)
040                    throws IOException, ServletException {
041    
042                    servletRequest.setAttribute(WebKeys.SERVLET_PATH, _path);
043    
044                    _requestDispatcher.forward(servletRequest, servletResponse);
045            }
046    
047            public void include(
048                            ServletRequest servletRequest, ServletResponse servletResponse)
049                    throws IOException, ServletException {
050    
051                    servletRequest.setAttribute(WebKeys.SERVLET_PATH, _path);
052    
053                    _requestDispatcher.include(servletRequest, servletResponse);
054            }
055    
056            private String _path;
057            private RequestDispatcher _requestDispatcher;
058    
059    }