01: /*
02: * All content copyright (c) 2003-2007 Terracotta, Inc., except as may otherwise be noted in a separate copyright notice. All rights reserved.
03: */
04: package com.tctest.webapp.servlets;
05:
06: import java.io.IOException;
07:
08: import javax.servlet.RequestDispatcher;
09: import javax.servlet.ServletException;
10: import javax.servlet.http.HttpServlet;
11: import javax.servlet.http.HttpServletRequest;
12: import javax.servlet.http.HttpServletResponse;
13:
14: public final class RequestForwardTestForwarderServlet extends
15: HttpServlet {
16: protected void doGet(HttpServletRequest req,
17: HttpServletResponse resp) throws IOException,
18: ServletException {
19: final String action = req.getParameter("action");
20: final String target = req.getParameter("target");
21: String reply = "OK";
22: RequestDispatcher requestDispatcher = req
23: .getRequestDispatcher(target);
24: System.err
25: .println("\n%%% ForwarderServlet.doGet is here...action="
26: + action + ", target=" + target);
27:
28: if ("s-f-s".equals(action)) {
29: req.getSession();
30: requestDispatcher.forward(req, resp);
31: req.getSession();
32: } else if ("n-f-s".equals(action)) {
33: requestDispatcher.forward(req, resp);
34: req.getSession();
35: } else if ("s-f-n".equals(action)) {
36: req.getSession();
37: System.err
38: .println("%%% ForwarderServlet: calling forward ...");
39: requestDispatcher.forward(req, resp);
40: System.err
41: .println("%%% ForwarderServlet: returned from forward forward ...");
42: } else {
43: reply = "INVALID REQUEST";
44: resp.getWriter().print(reply);
45: resp.flushBuffer();
46: }
47: }
48: }
|