01: /*
02: * Copyright (c) 1998-2008 Caucho Technology -- all rights reserved
03: *
04: * This file is part of Resin(R) Open Source
05: *
06: * Each copy or derived work must preserve the copyright notice and this
07: * notice unmodified.
08: *
09: * Resin Open Source is free software; you can redistribute it and/or modify
10: * it under the terms of the GNU General Public License as published by
11: * the Free Software Foundation; either version 2 of the License, or
12: * (at your option) any later version.
13: *
14: * Resin Open Source is distributed in the hope that it will be useful,
15: * but WITHOUT ANY WARRANTY; without even the implied warranty of
16: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, or any warranty
17: * of NON-INFRINGEMENT. See the GNU General Public License for more
18: * details.
19: *
20: * You should have received a copy of the GNU General Public License
21: * along with Resin Open Source; if not, write to the
22: * Free SoftwareFoundation, Inc.
23: * 59 Temple Place, Suite 330
24: * Boston, MA 02111-1307 USA
25: *
26: * @author Scott Ferguson
27: */
28:
29: package com.caucho.jsp;
30:
31: import com.caucho.server.webapp.WebApp;
32:
33: import javax.servlet.ServletConfig;
34: import javax.servlet.ServletException;
35: import javax.servlet.jsp.JspFactory;
36:
37: /**
38: * Handles XTP pages. Most of the work is done in the JspManager and QServlet.
39: *
40: * @see JspManager
41: */
42: public class XtpServlet extends QServlet {
43: static final String COPYRIGHT = "Copyright (c) 1998-2008 Caucho Technology. All rights reserved.";
44:
45: /**
46: * Initializes the servlet. Primarily, this sets the PageManager to the
47: * correct XtpManager.
48: *
49: * <p>The servlet parameter 'strict-xsl' forces XSL stylesheets to
50: * follow the strict specification. By default, XSL stylesheets follow
51: * the looser 'XSLT-lite.'
52: *
53: * <p>The servlet parameter 'strict-xml' forces XTP pages to
54: * follow strict XML. By default, they're LooseHtml.
55: *
56: * <p>The servlet parameter 'default-stylesheet' sets the default
57: * stylesheet. The initial value is 'default.xsl'.
58: */
59: public void init(ServletConfig conf) throws ServletException {
60: super .init(conf);
61:
62: XtpManager manager = new XtpManager();
63: manager.initWebApp((WebApp) getServletContext());
64:
65: setManager(manager);
66:
67: String strictXslValue = conf.getInitParameter("strict-xsl");
68: if (strictXslValue != null && !strictXslValue.equals("false")
69: && !strictXslValue.equals("no"))
70: manager.setStrictXsl(true);
71:
72: String strictXmlValue = conf.getInitParameter("strict-xml");
73: if (strictXmlValue != null && !strictXmlValue.equals("false")
74: && !strictXmlValue.equals("no"))
75: manager.setStrictXml(true);
76:
77: String entitiesAsText = conf
78: .getInitParameter("entities-as-text");
79: if (entitiesAsText != null && !entitiesAsText.equals("false")
80: && !entitiesAsText.equals("no"))
81: manager.setEntitiesAsText(true);
82:
83: String toLower = conf.getInitParameter("html-to-lower");
84: if (toLower != null
85: && (toLower.equals("no") || toLower.equals("false")))
86: manager.setToLower(false);
87:
88: String defaultStylesheet = getInitParameter("default-stylesheet");
89: if (defaultStylesheet != null && !defaultStylesheet.equals(""))
90: manager.setDefaultStylesheet(defaultStylesheet);
91:
92: if (JspFactory.getDefaultFactory() == null)
93: JspFactory.setDefaultFactory(QJspFactory.create());
94: }
95:
96: public String getServletInfo() {
97: return "XTP";
98: }
99: }
|