KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > caucho > jsp > XtpServlet


1 /*
2  * Copyright (c) 1998-2006 Caucho Technology -- all rights reserved
3  *
4  * This file is part of Resin(R) Open Source
5  *
6  * Each copy or derived work must preserve the copyright notice and this
7  * notice unmodified.
8  *
9  * 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 JavaDoc;
34 import javax.servlet.ServletException JavaDoc;
35 import javax.servlet.jsp.JspFactory JavaDoc;
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 JavaDoc COPYRIGHT =
44     "Copyright (c) 1998-2006 Caucho Technology. All rights reserved.";
45
46   /**
47    * Initializes the servlet. Primarily, this sets the PageManager to the
48    * correct XtpManager.
49    *
50    * <p>The servlet parameter 'strict-xsl' forces XSL stylesheets to
51    * follow the strict specification. By default, XSL stylesheets follow
52    * the looser 'XSLT-lite.'
53    *
54    * <p>The servlet parameter 'strict-xml' forces XTP pages to
55    * follow strict XML. By default, they're LooseHtml.
56    *
57    * <p>The servlet parameter 'default-stylesheet' sets the default
58    * stylesheet. The initial value is 'default.xsl'.
59    */

60   public void init(ServletConfig JavaDoc conf)
61     throws ServletException JavaDoc
62   {
63     super.init(conf);
64
65     XtpManager manager = new XtpManager();
66     manager.initWebApp((WebApp) getServletContext());
67       
68     setManager(manager);
69
70     String JavaDoc strictXslValue = conf.getInitParameter("strict-xsl");
71     if (strictXslValue != null &&
72     ! strictXslValue.equals("false") &&
73     ! strictXslValue.equals("no"))
74       manager.setStrictXsl(true);
75   
76     String JavaDoc strictXmlValue = conf.getInitParameter("strict-xml");
77     if (strictXmlValue != null &&
78     ! strictXmlValue.equals("false") &&
79     ! strictXmlValue.equals("no"))
80       manager.setStrictXml(true);
81       
82     String JavaDoc entitiesAsText = conf.getInitParameter("entities-as-text");
83     if (entitiesAsText != null &&
84     ! entitiesAsText.equals("false") &&
85     ! entitiesAsText.equals("no"))
86       manager.setEntitiesAsText(true);
87       
88     String JavaDoc toLower = conf.getInitParameter("html-to-lower");
89     if (toLower != null &&
90     (toLower.equals("no") || toLower.equals("false")))
91       manager.setToLower(false);
92
93     String JavaDoc defaultStylesheet = getInitParameter("default-stylesheet");
94     if (defaultStylesheet != null && ! defaultStylesheet.equals(""))
95       manager.setDefaultStylesheet(defaultStylesheet);
96
97     if (JspFactory.getDefaultFactory() == null)
98       JspFactory.setDefaultFactory(QJspFactory.create());
99   }
100
101   public String JavaDoc getServletInfo()
102   {
103     return "XTP";
104   }
105 }
106
Popular Tags