01: /*
02: * JFolder, Copyright 2001-2006 Gary Steinmetz
03: *
04: * Distributable under LGPL license.
05: * See terms of license at gnu.org.
06: */
07:
08: package org.jfolder.platforms.servers.instances.tomcat;
09:
10: //base classes
11: import java.io.IOException;
12: import java.io.PrintWriter;
13: import javax.servlet.RequestDispatcher;
14: import javax.servlet.ServletException;
15: import javax.servlet.http.HttpServlet;
16: import javax.servlet.http.HttpServletRequest;
17: import javax.servlet.http.HttpServletResponse;
18: import javax.servlet.http.HttpSession;
19:
20: //project specific classes
21:
22: //other classes
23:
24: public class TomcatWebPageServlet extends HttpServlet {
25:
26: public TomcatWebPageServlet() {
27: }
28:
29: public void service(HttpServletRequest inRequest,
30: HttpServletResponse inResponse) throws IOException,
31: ServletException {
32:
33: //PrintWriter pw = inResponse.getWriter();
34: //pw.println("<html><body>TomcatWebPageServlet</body></html>");
35: //pw.flush();
36: //pw.close();
37:
38: //declare session
39: HttpSession hs = inRequest.getSession();
40:
41: //application
42: String destination = inRequest.getServletPath();
43: if (destination.startsWith("/")) {
44: destination = destination.substring(1);
45: }
46: if (destination.endsWith("/")) {
47: //
48: destination = destination.substring(0,
49: destination.length() - 1);
50: }
51: //destination
52: //String servletPath = inRequest.getContextPath();
53: //if (servletPath.startsWith("/")) {
54: // servletPath = servletPath.substring(1);
55: //}
56: //if (servletPath.endsWith("/")) {
57: // servletPath =
58: // servletPath.substring(0, servletPath.length() - 1);
59: //}
60:
61: //MiscHelper.println("About to dispatch to parent.jsp");
62: //inResponse.setContentType("text/html");
63: //
64: String destinationPage = (new TomcatServer())
65: .getRelativeWebPageLocation(destination);
66: //
67: //
68: RequestDispatcher rd = inRequest
69: .getRequestDispatcher(destinationPage);
70: rd.include(inRequest, inResponse);
71: //MiscHelper.println("Finished to dispatch to parent.jsp");
72: }
73: }
|