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.sun.portal.providers.jsp.jasper3.jasper;
058:
059: import java.util.ResourceBundle;
060: import java.util.MissingResourceException;
061: import java.text.MessageFormat;
062:
063: import com.sun.portal.providers.jsp.jasper3.tomcat.logging.Logger;
064:
065: /**
066: * Some constants and other global data that are used by the compiler and the runtime.
067: *
068: * @author Anil K. Vijendran
069: * @author Harish Prabandham
070: */
071: public class Constants {
072: /**
073: * The base class of the generated servlets.
074: */
075: public static final String JSP_SERVLET_BASE = "HttpJspBase";
076:
077: /**
078: * _jspService is the name of the method that is called by
079: * HttpJspBase.service(). This is where most of the code generated
080: * from JSPs go.
081: */
082: public static final String SERVICE_METHOD_NAME = "_jspService";
083:
084: /**
085: * Default servlet content type.
086: */
087: public static final String SERVLET_CONTENT_TYPE = "text/html";
088:
089: /**
090: * These classes/packages are automatically imported by the
091: * generated code.
092: *
093: * FIXME: Need to trim this to what is there in PR2 and verify
094: * with all our generators -akv.
095: */
096: public static final String[] STANDARD_IMPORTS = {
097: "javax.servlet.*", "javax.servlet.http.*",
098: "javax.servlet.jsp.*", "javax.servlet.jsp.tagext.*",
099: "java.io.PrintWriter", "java.io.IOException",
100: "java.io.FileInputStream", "java.io.ObjectInputStream",
101: "java.util.Vector",
102: "com.sun.portal.providers.jsp.jasper3.jasper.runtime.*",
103: "java.beans.*",
104: "com.sun.portal.providers.jsp.jasper3.jasper.JasperException" };
105:
106: /**
107: * ServletContext attribute for classpath. This is tomcat specific.
108: * Other servlet engines can choose to have this attribute if they
109: * want to have this JSP engine running on them.
110: */
111: public static final String SERVLET_CLASSPATH = "com.iplanet.server.http.servlet.classpath";
112:
113: /**
114: * iPlanet specific attribute for checking on jsp freshness
115: */
116: public static final String JSP_RELOAD_INTERVAL = "com.iplanet.server.http.servlet.reload-interval";
117:
118: /**
119: * ServletContext attribute for classpath. This is tomcat specific.
120: * Other servlet engines can choose to have this attribute if they
121: * want to have this JSP engine running on them.
122: */
123: public static final String SERVLET_CLASS_LOADER = "com.iplanet.server.http.servlet.classloader";
124:
125: /**
126: * Default size of the JSP buffer.
127: */
128: public static final int K = 1024;
129: public static final int DEFAULT_BUFFER_SIZE = 8 * K;
130:
131: /**
132: * The query parameter that causes the JSP engine to just
133: * pregenerated the servlet but not invoke it.
134: */
135: public static final String PRECOMPILE = "jsp_precompile";
136:
137: /**
138: * Servlet context and request attributes that the JSP engine
139: * uses.
140: */
141: public static final String INC_REQUEST_URI = "javax.servlet.include.request_uri";
142: public static final String INC_SERVLET_PATH = "javax.servlet.include.servlet_path";
143: public static final String TMP_DIR = "javax.servlet.context.tempdir";
144:
145: /**
146: * ProtectionDomain to use for JspLoader defineClass() for current
147: * Context when using a SecurityManager.
148: */
149: public static final String ATTRIB_JSP_ProtectionDomain = "tomcat.context.jsp.protection_domain";
150:
151: /**
152: * A token which is embedded in file names of the generated
153: * servlet.
154: */
155: public static final String JSP_TOKEN = "_jsp";
156:
157: /**
158: * The directory in which jsp servlets are generated
159: */
160: public static final String JSP_DIR = "_jsps";
161:
162: /**
163: * ID and location of the DTD for tag library descriptors.
164: */
165: public static final String TAGLIB_DTD_PUBLIC_ID = "-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.1//EN";
166: public static final String TAGLIB_DTD_RESOURCE = "/com/sun/portal/providers/jsp/jasper3/jasper/resources/web-jsptaglib_1_1.dtd";
167:
168: /**
169: * ID and location of the DTD for web-app deployment descriptors.
170: */
171: public static final String WEBAPP_DTD_PUBLIC_ID = "-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN";
172: public static final String WEBAPP_DTD_RESOURCE = "/com/sun/portal/providers/jsp/jasper3/jasper/resources/web.dtd";
173:
174: /**
175: * Default URLs to download the pluging for Netscape and IE.
176: */
177: public static final String NS_PLUGIN_URL = "http://java.sun.com/products/plugin/";
178:
179: 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";
180:
181: /**
182: * Default plugin class ID for versions 4 and 5 of IE.
183: */
184: public static final String IE_PLUGIN_CLASSID = "clsid:8AD9C840-044E-11D1-B3E9-00805F499D93";
185:
186: /**
187: * This is where all our error messages and such are stored.
188: */
189: private static ResourceBundle resources;
190:
191: private static void initResources() throws MissingResourceException {
192: resources = ResourceBundle
193: .getBundle("com.sun.portal.providers.jsp.jasper3.jasper.resources.messages");
194: }
195:
196: /**
197: * Get hold of a "message" or any string from our resources
198: * database.
199: */
200: public static final String getString(String key) {
201: return getString(key, null);
202: }
203:
204: /**
205: * Format the string that is looked up using "key" using "args".
206: */
207: public static final String getString(String key, Object[] args)
208: throws MissingResourceException {
209: if (resources == null)
210: initResources();
211:
212: String msg = resources.getString(key);
213: if (args == null)
214: return msg;
215: MessageFormat form = new MessageFormat(msg);
216: return form.format(args);
217: }
218:
219: /**
220: * Print a message into standard error with a certain verbosity
221: * level.
222: *
223: * @param key is used to look up the text for the message (using
224: * getString()).
225: * @param verbosityLevel is used to determine if this output is
226: * appropriate for the current verbosity
227: * level.
228: */
229: public static final void message(String key, int verbosityLevel) {
230: message(key, null, verbosityLevel);
231: }
232:
233: /**
234: * Print a message into standard error with a certain verbosity
235: * level after formatting it using "args".
236: *
237: * @param key is used to look up the message.
238: * @param args is used to format the message.
239: * @param verbosityLevel is used to determine if this output is
240: * appropriate for the current verbosity
241: * level.
242: */
243: public static final void message(String key, Object[] args,
244: int verbosityLevel) {
245: if (jasperLog == null)
246: jasperLog = Logger.getLogger("JASPER_LOG");
247:
248: if (jasperLog != null)
249: jasperLog.log(getString(key, args), verbosityLevel);
250: }
251:
252: public static Logger jasperLog = null;
253: }
|