001: /*
002: * The Apache Software License, Version 1.1
003: *
004: * Copyright (c) 1999 The Apache Software Foundation. All rights
005: * reserved.
006: *
007: * Redistribution and use in source and binary forms, with or without
008: * modification, are permitted provided that the following conditions
009: * are met:
010: *
011: * 1. Redistributions of source code must retain the above copyright
012: * notice, this list of conditions and the following disclaimer.
013: *
014: * 2. Redistributions in binary form must reproduce the above copyright
015: * notice, this list of conditions and the following disclaimer in
016: * the documentation and/or other materials provided with the
017: * distribution.
018: *
019: * 3. The end-user documentation included with the redistribution, if
020: * any, must include the following acknowlegement:
021: * "This product includes software developed by the
022: * Apache Software Foundation (http://www.apache.org/)."
023: * Alternately, this acknowlegement may appear in the software itself,
024: * if and wherever such third-party acknowlegements normally appear.
025: *
026: * 4. The names "The Jakarta Project", "Tomcat", and "Apache Software
027: * Foundation" must not be used to endorse or promote products derived
028: * from this software without prior written permission. For written
029: * permission, please contact apache@apache.org.
030: *
031: * 5. Products derived from this software may not be called "Apache"
032: * nor may "Apache" appear in their names without prior written
033: * permission of the Apache Group.
034: *
035: * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
036: * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
037: * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
038: * DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR
039: * ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
040: * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
041: * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
042: * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
043: * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
044: * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
045: * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
046: * SUCH DAMAGE.
047: * ====================================================================
048: *
049: * This software consists of voluntary contributions made by many
050: * individuals on behalf of the Apache Software Foundation. For more
051: * information on the Apache Software Foundation, please see
052: * <http://www.apache.org/>.
053: *
054: *
055: */
056:
057: package com.rimfaxe.webserver.compiler.jsp;
058:
059: import java.util.ResourceBundle;
060: import java.util.MissingResourceException;
061: import java.text.MessageFormat;
062:
063: /**
064: * Some constants and other global data that are used by the compiler and the runtime.
065: *
066: * @author Anil K. Vijendran
067: * @author Harish Prabandham
068: * @author Lars Andersen
069: */
070: public class Constants {
071: /**
072: * The base class of the generated servlets.
073: */
074: public static final String JSP_SERVLET_BASE = "HttpJspBase";
075:
076: /**
077: * _jspService is the name of the method that is called by
078: * HttpJspBase.service(). This is where most of the code generated
079: * from JSPs go.
080: */
081: public static final String SERVICE_METHOD_NAME = "_jspService";
082:
083: /**
084: * Default servlet content type.
085: */
086: public static final String SERVLET_CONTENT_TYPE = "text/html";
087:
088: /**
089: * These classes/packages are automatically imported by the
090: * generated code.
091: */
092: public static final String[] STANDARD_IMPORTS = {
093: "javax.servlet.*", "javax.servlet.http.*",
094: "javax.servlet.jsp.*", "com.rimfaxe.webserver.runtime.*", };
095:
096: /**
097: * FIXME
098: * ServletContext attribute for classpath. This is tomcat specific.
099: * Other servlet engines can choose to have this attribute if they
100: * want to have this JSP engine running on them.
101: */
102: //public static final String SERVLET_CLASSPATH = "org.apache.tomcat.jsp_classpath";
103: public static final String SERVLET_CLASSPATH = "org.apache.catalina.jsp_classpath";
104:
105: /**
106: * FIXME
107: * Request attribute for <code><jsp-file></code> element of a
108: * servlet definition. If present on a request, this overrides the
109: * value returned by <code>request.getServletPath()</code> to select
110: * the JSP page to be executed.
111: */
112: public static final String JSP_FILE = "org.apache.catalina.jsp_file";
113:
114: /**
115: * FIXME
116: * ServletContext attribute for class loader. This is tomcat specific.
117: * Other servlet engines can choose to have this attribute if they
118: * want to have this JSP engine running on them.
119: */
120: //public static final String SERVLET_CLASS_LOADER = "org.apache.tomcat.classloader";
121: public static final String SERVLET_CLASS_LOADER = "org.apache.catalina.classloader";
122:
123: /**
124: * Default size of the JSP buffer.
125: */
126: public static final int K = 1024;
127: public static final int DEFAULT_BUFFER_SIZE = 8 * K;
128:
129: /**
130: * Default size for the tag buffers.
131: */
132: public static final int DEFAULT_TAG_BUFFER_SIZE = 512;
133:
134: /**
135: * The query parameter that causes the JSP engine to just
136: * pregenerated the servlet but not invoke it.
137: */
138: public static final String PRECOMPILE = "jsp_precompile";
139:
140: /**
141: * The default package name for compiled jsp pages.
142: */
143: public static final String JSP_PACKAGE_NAME = "org.apache.jsp";
144:
145: /**
146: * Servlet context and request attributes that the JSP engine
147: * uses.
148: */
149: public static final String INC_REQUEST_URI = "javax.servlet.include.request_uri";
150: public static final String INC_SERVLET_PATH = "javax.servlet.include.servlet_path";
151: public static final String TMP_DIR = "javax.servlet.context.tempdir";
152: public static final String FORWARD_SEEN = "javax.servlet.forward.seen";
153:
154: /**
155: * Public Id and the Resource path (of the cached copy)
156: * of the DTDs for tag library descriptors.
157: */
158: public static final String TAGLIB_DTD_PUBLIC_ID_11 = "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.1//EN";
159: public static final String TAGLIB_DTD_RESOURCE_PATH_11 = "/javax/servlet/jsp/resources/web-jsptaglibrary_1_1.dtd";
160: public static final String TAGLIB_DTD_PUBLIC_ID_12 = "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.2//EN";
161: public static final String TAGLIB_DTD_RESOURCE_PATH_12 = "/javax/servlet/jsp/resources/web-jsptaglibrary_1_2.dtd";
162:
163: /**
164: * Public Id and the Resource path (of the cached copy)
165: * of the DTDs for web application deployment descriptors
166: */
167: public static final String WEBAPP_DTD_PUBLIC_ID_22 = "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN";
168: public static final String WEBAPP_DTD_RESOURCE_PATH_22 = "/javax/servlet/resources/web-app_2_2.dtd";
169: public static final String WEBAPP_DTD_PUBLIC_ID_23 = "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN";
170: public static final String WEBAPP_DTD_RESOURCE_PATH_23 = "/javax/servlet/resources/web-app_2_3.dtd";
171:
172: /**
173: * List of the Public IDs that we cache, and their
174: * associated location. This is used by
175: * an EntityResolver to return the location of the
176: * cached copy of a DTD.
177: */
178: public static final String[] CACHED_DTD_PUBLIC_IDS = {
179: TAGLIB_DTD_PUBLIC_ID_11, TAGLIB_DTD_PUBLIC_ID_12,
180: WEBAPP_DTD_PUBLIC_ID_22, WEBAPP_DTD_PUBLIC_ID_23, };
181: public static final String[] CACHED_DTD_RESOURCE_PATHS = {
182: TAGLIB_DTD_RESOURCE_PATH_11, TAGLIB_DTD_RESOURCE_PATH_12,
183: WEBAPP_DTD_RESOURCE_PATH_22, WEBAPP_DTD_RESOURCE_PATH_23, };
184:
185: /**
186: * Default URLs to download the pluging for Netscape and IE.
187: */
188: public static final String NS_PLUGIN_URL = "http://java.sun.com/products/plugin/";
189:
190: public static final String IE_PLUGIN_URL = "http://java.sun.com/products/plugin/1.2.2/jinstall-1_2_2-win.cab#Version=1,2,2,0";
191:
192: /**
193: * This is where all our error messages and such are stored.
194: */
195: private static ResourceBundle resources;
196:
197: private static void initResources() {
198: try {
199: resources = ResourceBundle
200: .getBundle("org.apache.jasper.resources.messages");
201: } catch (MissingResourceException e) {
202: throw new Error("Fatal Error: missing resource bundle: "
203: + e.getClassName());
204: }
205: }
206:
207: /**
208: * Get hold of a "message" or any string from our resources
209: * database.
210: */
211: public static final String getString(String key) {
212: return getString(key, null);
213: }
214:
215: /**
216: * Format the string that is looked up using "key" using "args".
217: */
218: public static final String getString(String key, Object[] args) {
219: System.out.println("Constants.getString(" + key
220: + ",Object[] args)");
221: if (resources == null)
222: initResources();
223:
224: try {
225: String msg = resources.getString(key);
226: if (args == null)
227: return msg;
228: MessageFormat form = new MessageFormat(msg);
229: return form.format(args);
230: } catch (MissingResourceException ignore) {
231: throw new Error("Fatal Error: missing resource: "
232: + ignore.getClassName());
233: }
234: }
235:
236: /**
237: * Print a message into standard error with a certain verbosity
238: * level.
239: *
240: * @param key is used to look up the text for the message (using
241: * getString()).
242: * @param verbosityLevel is used to determine if this output is
243: * appropriate for the current verbosity
244: * level.
245: */
246: public static final void message(String key, int verbosityLevel) {
247: message(key, null, verbosityLevel);
248: }
249:
250: /**
251: * Print a message into standard error with a certain verbosity
252: * level after formatting it using "args".
253: *
254: * @param key is used to look up the message.
255: * @param args is used to format the message.
256: * @param verbosityLevel is used to determine if this output is
257: * appropriate for the current verbosity
258: * level.
259: */
260: public static final void message(String key, Object[] args,
261: int verbosityLevel) {
262:
263: }
264:
265: //public static Logger jasperLog = null;
266: }
|