Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 7ce012943dcb4046ae9e252c16857f568f2f9c2d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
/*******************************************************************************
 * Copyright (c) 2005, 2016 Cognos Incorporated, IBM Corporation and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     Cognos Incorporated - initial API and implementation
 *     IBM Corporation - bug fixes and enhancements
 *     Raymond Augé <raymond.auge@liferay.com> - Bug 436698
 *******************************************************************************/
package org.eclipse.equinox.http.servlet.internal.servlet;

import java.io.IOException;
import javax.servlet.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.eclipse.equinox.http.servlet.internal.context.DispatchTargets;

//This class unwraps the request so it can be processed by the underlying servlet container.
public class RequestDispatcherAdaptor implements RequestDispatcher {

	private static final String SIMPLE_NAME = RequestDispatcherAdaptor.class.getSimpleName();

	private final DispatchTargets dispatchTargets;
	private final String path;
	private String string;

	public RequestDispatcherAdaptor(
		DispatchTargets dispatchTargets, String path) {

		this.dispatchTargets = dispatchTargets;
		this.path = path;
	}

	public void forward(ServletRequest request, ServletResponse response)
		throws IOException, ServletException {

		dispatchTargets.doDispatch(
			(HttpServletRequest)request, (HttpServletResponse)response,
			path, DispatcherType.FORWARD);
	}

	public void include(ServletRequest request, ServletResponse response)
		throws IOException, ServletException {

		dispatchTargets.doDispatch(
			(HttpServletRequest)request, (HttpServletResponse)response,
			path, DispatcherType.INCLUDE);
	}

	@Override
	public String toString() {
		String value = string;

		if (value == null) {
			value = SIMPLE_NAME + '[' + path + ", " + dispatchTargets + ']'; //$NON-NLS-1$

			string = value;
		}

		return value;
	}

}

Back to the top