You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by fm...@apache.org on 2007/11/26 17:15:53 UTC

svn commit: r598331 [1/22] - in /incubator/sling/trunk/scripting/jsp: ./ src/main/java/org/apache/jasper/ src/main/java/org/apache/jasper/compiler/ src/main/java/org/apache/jasper/compiler/tagplugin/ src/main/java/org/apache/jasper/runtime/ src/main/ja...

Author: fmeschbe
Date: Mon Nov 26 08:15:43 2007
New Revision: 598331

URL: http://svn.apache.org/viewvc?rev=598331&view=rev
Log:
SLING-98 Migrate JSP scripting support
  + plus include Jasper Compiler and EL implementation

Added:
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/jasper/
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/jasper/Constants.java
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/jasper/EmbeddedServletOptions.java
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/jasper/JasperException.java
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/jasper/JspCompilationContext.java
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/jasper/Options.java
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/jasper/OutputProvider.java
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/jasper/compiler/
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/jasper/compiler/BeanRepository.java
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/jasper/compiler/Collector.java
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/jasper/compiler/Compiler.java
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/jasper/compiler/DefaultErrorHandler.java
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/jasper/compiler/Dumper.java
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/jasper/compiler/ELFunctionMapper.java
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/jasper/compiler/ELNode.java
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/jasper/compiler/ELParser.java
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/jasper/compiler/ErrorDispatcher.java
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/jasper/compiler/ErrorHandler.java
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/jasper/compiler/Generator.java
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/jasper/compiler/ImplicitTagLibraryInfo.java
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/jasper/compiler/JDTCompiler.java
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/jasper/compiler/JasperTagInfo.java
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/jasper/compiler/JavacErrorDetail.java
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/jasper/compiler/JspConfig.java
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/jasper/compiler/JspDocumentParser.java
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/jasper/compiler/JspReader.java
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/jasper/compiler/JspRuntimeContext.java
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/jasper/compiler/JspUtil.java
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/jasper/compiler/Localizer.java
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/jasper/compiler/Mark.java
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/jasper/compiler/Node.java
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/jasper/compiler/PageDataImpl.java
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/jasper/compiler/PageInfo.java
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/jasper/compiler/Parser.java
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/jasper/compiler/ParserController.java
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/jasper/compiler/ScriptingVariabler.java
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/jasper/compiler/ServletWriter.java
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/jasper/compiler/SmapGenerator.java
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/jasper/compiler/SmapStratum.java
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/jasper/compiler/SmapUtil.java
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/jasper/compiler/TagConstants.java
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/jasper/compiler/TagFileProcessor.java
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/jasper/compiler/TagLibraryInfoImpl.java
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/jasper/compiler/TagPluginManager.java
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/jasper/compiler/TextOptimizer.java
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/jasper/compiler/TldLocationsCache.java
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/jasper/compiler/Validator.java
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/jasper/compiler/tagplugin/
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/jasper/compiler/tagplugin/TagPlugin.java
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/jasper/compiler/tagplugin/TagPluginContext.java
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/jasper/runtime/
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/jasper/runtime/BodyContentImpl.java
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/jasper/runtime/HttpJspBase.java
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/jasper/runtime/JspContextWrapper.java
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/jasper/runtime/JspFactoryImpl.java
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/jasper/runtime/JspFragmentHelper.java
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/jasper/runtime/JspRuntimeLibrary.java
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/jasper/runtime/JspSourceDependent.java
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/jasper/runtime/JspWriterImpl.java
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/jasper/runtime/PageContextImpl.java
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/jasper/runtime/PerThreadTagHandlerPool.java
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/jasper/runtime/ProtectedFunctionMapper.java
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/jasper/runtime/ServletResponseWrapperInclude.java
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/jasper/runtime/TagHandlerPool.java
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/jasper/security/
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/jasper/security/SecurityClassLoad.java
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/jasper/security/SecurityUtil.java
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/jasper/servlet/
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/jasper/servlet/JasperLoader.java
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/jasper/servlet/JspServlet.java
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/jasper/servlet/JspServletWrapper.java
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/jasper/tagplugins/
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/jasper/tagplugins/jstl/
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/jasper/tagplugins/jstl/Util.java
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/jasper/tagplugins/jstl/core/
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/jasper/tagplugins/jstl/core/Catch.java
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/jasper/tagplugins/jstl/core/Choose.java
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/jasper/tagplugins/jstl/core/ForEach.java
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/jasper/tagplugins/jstl/core/ForTokens.java
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/jasper/tagplugins/jstl/core/If.java
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/jasper/tagplugins/jstl/core/Import.java
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/jasper/tagplugins/jstl/core/Otherwise.java
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/jasper/tagplugins/jstl/core/Out.java
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/jasper/tagplugins/jstl/core/Param.java
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/jasper/tagplugins/jstl/core/Redirect.java
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/jasper/tagplugins/jstl/core/Remove.java
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/jasper/tagplugins/jstl/core/Set.java
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/jasper/tagplugins/jstl/core/Url.java
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/jasper/tagplugins/jstl/core/When.java
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/jasper/util/
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/jasper/util/FastDateFormat.java
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/jasper/util/Queue.java
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/jasper/util/SimplePool.java
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/jasper/util/SystemLogHandler.java
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/jasper/xmlparser/
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/jasper/xmlparser/ASCIIReader.java
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/jasper/xmlparser/EncodingMap.java
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/jasper/xmlparser/ParserUtils.java
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/jasper/xmlparser/SymbolTable.java
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/jasper/xmlparser/TreeNode.java
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/jasper/xmlparser/UCSReader.java
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/jasper/xmlparser/UTF8Reader.java
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/jasper/xmlparser/XMLChar.java
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/jasper/xmlparser/XMLEncodingDetector.java
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/jasper/xmlparser/XMLString.java
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/jasper/xmlparser/XMLStringBuffer.java
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/util/JspSlingHttpServletResponseWrapper.java
      - copied, changed from r598308, incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/util/JspComponentResponseWrapper.java
    incubator/sling/trunk/scripting/jsp/src/main/resources/org/
    incubator/sling/trunk/scripting/jsp/src/main/resources/org/apache/
    incubator/sling/trunk/scripting/jsp/src/main/resources/org/apache/jasper/
    incubator/sling/trunk/scripting/jsp/src/main/resources/org/apache/jasper/resources/
    incubator/sling/trunk/scripting/jsp/src/main/resources/org/apache/jasper/resources/LocalStrings.properties
    incubator/sling/trunk/scripting/jsp/src/main/resources/org/apache/jasper/resources/LocalStrings_es.properties
    incubator/sling/trunk/scripting/jsp/src/main/resources/org/apache/jasper/resources/LocalStrings_fr.properties
    incubator/sling/trunk/scripting/jsp/src/main/resources/org/apache/jasper/resources/LocalStrings_ja.properties
    incubator/sling/trunk/scripting/jsp/src/main/resources/org/apache/jasper/servlet/
    incubator/sling/trunk/scripting/jsp/src/main/resources/org/apache/jasper/servlet/mbeans-descriptors.xml
    incubator/sling/trunk/scripting/jsp/src/main/resources/org/apache/jasper/tagplugins/
    incubator/sling/trunk/scripting/jsp/src/main/resources/org/apache/jasper/tagplugins/jstl/
    incubator/sling/trunk/scripting/jsp/src/main/resources/org/apache/jasper/tagplugins/jstl/tagPlugins.xml
Removed:
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/util/JspComponentResponseWrapper.java
Modified:
    incubator/sling/trunk/scripting/jsp/pom.xml
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/JspScriptHandler.java
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/JspServletContext.java
    incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/sling/scripting/jsp/JspServletWrapperAdapter.java

Modified: incubator/sling/trunk/scripting/jsp/pom.xml
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/scripting/jsp/pom.xml?rev=598331&r1=598330&r2=598331&view=diff
==============================================================================
--- incubator/sling/trunk/scripting/jsp/pom.xml (original)
+++ incubator/sling/trunk/scripting/jsp/pom.xml Mon Nov 26 08:15:43 2007
@@ -1,21 +1,21 @@
 <?xml version="1.0" encoding="ISO-8859-1"?>
 <!--
-  Licensed to the Apache Software Foundation (ASF) under one
-  or more contributor license agreements.  See the NOTICE file
-  distributed with this work for additional information
-  regarding copyright ownership.  The ASF licenses this file
-  to you under the Apache License, Version 2.0 (the
-  "License"); you may not use this file except in compliance
-  with the License.  You may obtain a copy of the License at
-
-   http://www.apache.org/licenses/LICENSE-2.0
-
-  Unless required by applicable law or agreed to in writing,
-  software distributed under the License is distributed on an
-  "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-  KIND, either express or implied.  See the License for the
-  specific language governing permissions and limitations
-  under the License.
+    Licensed to the Apache Software Foundation (ASF) under one
+    or more contributor license agreements.  See the NOTICE file
+    distributed with this work for additional information
+    regarding copyright ownership.  The ASF licenses this file
+    to you under the Apache License, Version 2.0 (the
+    "License"); you may not use this file except in compliance
+    with the License.  You may obtain a copy of the License at
+    
+    http://www.apache.org/licenses/LICENSE-2.0
+    
+    Unless required by applicable law or agreed to in writing,
+    software distributed under the License is distributed on an
+    "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+    KIND, either express or implied.  See the License for the
+    specific language governing permissions and limitations
+    under the License.
 -->
 <project xmlns="http://maven.apache.org/POM/4.0.0"
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
@@ -67,9 +67,14 @@
                             org.apache.sling.scripting.jsp.util
                         </Export-Package>
                         <Private-Package>
-                            org.apache.sling.scripting.jsp.*
+                            org.apache.sling.scripting.jsp.*,
+                            org.apache.commons.el.*,
+                            org.apache.jasper.*, org.eclipse.jdt.*
                         </Private-Package>
                         <DynamicImport-Package>*</DynamicImport-Package>
+                        <Import-Package>
+                            org.eclipse.*;resolution:=optional, *
+                        </Import-Package>
                     </instructions>
                 </configuration>
             </plugin>
@@ -79,40 +84,45 @@
     <dependencies>
         <dependency>
             <groupId>org.apache.sling</groupId>
-            <artifactId>sling-component-api</artifactId>
+            <artifactId>org.apache.sling.api</artifactId>
             <version>2.0.0-incubator-SNAPSHOT</version>
         </dependency>
         <dependency>
             <groupId>org.apache.sling</groupId>
-            <artifactId>sling-content-jcr</artifactId>
+            <artifactId>org.apache.sling.jcr.resource</artifactId>
             <version>2.0.0-incubator-SNAPSHOT</version>
         </dependency>
         <dependency>
             <groupId>org.apache.sling</groupId>
-            <artifactId>sling-core</artifactId>
+            <artifactId>org.apache.sling.core</artifactId>
             <version>2.0.0-incubator-SNAPSHOT</version>
         </dependency>
         <dependency>
             <groupId>org.apache.sling</groupId>
-            <artifactId>sling-jackrabbit-api</artifactId>
+            <artifactId>org.apache.sling.jcr.api</artifactId>
             <version>2.0.0-incubator-SNAPSHOT</version>
         </dependency>
         <dependency>
             <groupId>org.apache.sling</groupId>
-            <artifactId>sling-scripting-core</artifactId>
+            <artifactId>org.apache.sling.jcr.classloader</artifactId>
             <version>2.0.0-incubator-SNAPSHOT</version>
         </dependency>
+
         <dependency>
-            <groupId>org.apache.sling</groupId>
-            <artifactId>sling-jackrabbit-classloader</artifactId>
-            <version>2.0.0-incubator-SNAPSHOT</version>
+            <groupId>org.eclipse.jdt</groupId>
+            <artifactId>core</artifactId>
+            <version>3.2.0.658</version>
         </dependency>
         <dependency>
-            <groupId>org.apache.sling</groupId>
-            <artifactId>sling-jasper-sling</artifactId>
-            <version>2.0.0-incubator-SNAPSHOT</version>
-            <scope>provided</scope>
+            <groupId>commons-el</groupId>
+            <artifactId>commons-el</artifactId>
+            <version>1.0</version>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.commons</groupId>
+            <artifactId>commons-io</artifactId>
         </dependency>
+
         <dependency>
             <groupId>org.osgi</groupId>
             <artifactId>osgi_R4_core</artifactId>

Added: incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/jasper/Constants.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/jasper/Constants.java?rev=598331&view=auto
==============================================================================
--- incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/jasper/Constants.java (added)
+++ incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/jasper/Constants.java Mon Nov 26 08:15:43 2007
@@ -0,0 +1,194 @@
+/*
+ * Copyright 1999,2004 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.jasper;
+
+
+/**
+ * Some constants and other global data that are used by the compiler and the runtime.
+ *
+ * @author Anil K. Vijendran
+ * @author Harish Prabandham
+ * @author Shawn Bayern
+ * @author Mark Roth
+ */
+public class Constants {
+    /**
+     * The base class of the generated servlets. 
+     */
+    public static final String JSP_SERVLET_BASE = "org.apache.jasper.runtime.HttpJspBase";
+
+    /**
+     * _jspService is the name of the method that is called by 
+     * HttpJspBase.service(). This is where most of the code generated
+     * from JSPs go.
+     */
+    public static final String SERVICE_METHOD_NAME = "_jspService";
+
+    /**
+     * Default servlet content type.
+     */
+    public static final String SERVLET_CONTENT_TYPE = "text/html";
+
+    /**
+     * These classes/packages are automatically imported by the
+     * generated code. 
+     */
+    public static final String[] STANDARD_IMPORTS = { 
+	"javax.servlet.*", 
+	"javax.servlet.http.*", 
+	"javax.servlet.jsp.*"
+    };
+
+    /**
+     * FIXME
+     * ServletContext attribute for classpath. This is tomcat specific. 
+     * Other servlet engines may choose to support this attribute if they 
+     * want to have this JSP engine running on them. 
+     */
+    public static final String SERVLET_CLASSPATH = "org.apache.catalina.jsp_classpath";
+
+    /**
+     * FIXME
+     * Request attribute for <code>&lt;jsp-file&gt;</code> element of a
+     * servlet definition.  If present on a request, this overrides the
+     * value returned by <code>request.getServletPath()</code> to select
+     * the JSP page to be executed.
+     */
+    public static final String JSP_FILE = "org.apache.catalina.jsp_file";
+
+
+    /**
+     * FIXME
+     * ServletContext attribute for class loader. This is tomcat specific. 
+     * Other servlet engines can choose to have this attribute if they 
+     * want to have this JSP engine running on them. 
+     */
+    //public static final String SERVLET_CLASS_LOADER = "org.apache.tomcat.classloader";
+    public static final String SERVLET_CLASS_LOADER = "org.apache.catalina.classloader";
+
+    /**
+     * Default size of the JSP buffer.
+     */
+    public static final int K = 1024;
+    public static final int DEFAULT_BUFFER_SIZE = 8*K;
+
+    /**
+     * Default size for the tag buffers.
+     */
+    public static final int DEFAULT_TAG_BUFFER_SIZE = 512;
+
+    /**
+     * Default tag handler pool size.
+     */
+    public static final int MAX_POOL_SIZE = 5;
+
+    /**
+     * The query parameter that causes the JSP engine to just
+     * pregenerated the servlet but not invoke it. 
+     */
+    public static final String PRECOMPILE = "jsp_precompile";
+
+    /**
+     * The default package name for compiled jsp pages.
+     */
+    public static final String JSP_PACKAGE_NAME = "org.apache.jsp";
+
+    /**
+     * The default package name for tag handlers generated from tag files
+     */
+    public static final String TAG_FILE_PACKAGE_NAME = "org.apache.jsp.tag";
+
+    /**
+     * Servlet context and request attributes that the JSP engine
+     * uses. 
+     */
+    public static final String INC_REQUEST_URI = "javax.servlet.include.request_uri";
+    public static final String INC_SERVLET_PATH = "javax.servlet.include.servlet_path";
+    public static final String TMP_DIR = "javax.servlet.context.tempdir";
+    public static final String FORWARD_SEEN = "javax.servlet.forward.seen";
+
+    // Must be kept in sync with org/apache/catalina/Globals.java
+    public static final String ALT_DD_ATTR = "org.apache.catalina.deploy.alt_dd";
+
+    /**
+     * Public Id and the Resource path (of the cached copy) 
+     * of the DTDs for tag library descriptors. 
+     */
+    public static final String TAGLIB_DTD_PUBLIC_ID_11 = 
+	"-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.1//EN";
+    public static final String TAGLIB_DTD_RESOURCE_PATH_11 = 
+	"/javax/servlet/jsp/resources/web-jsptaglibrary_1_1.dtd";
+    public static final String TAGLIB_DTD_PUBLIC_ID_12 = 
+	"-//Sun Microsystems, Inc.//DTD JSP Tag Library 1.2//EN";
+    public static final String TAGLIB_DTD_RESOURCE_PATH_12 = 
+	"/javax/servlet/jsp/resources/web-jsptaglibrary_1_2.dtd";
+
+    /**
+     * Public Id and the Resource path (of the cached copy) 
+     * of the DTDs for web application deployment descriptors
+     */
+    public static final String WEBAPP_DTD_PUBLIC_ID_22 = 
+	"-//Sun Microsystems, Inc.//DTD Web Application 2.2//EN";
+    public static final String WEBAPP_DTD_RESOURCE_PATH_22 = 
+	"/javax/servlet/resources/web-app_2_2.dtd";
+    public static final String WEBAPP_DTD_PUBLIC_ID_23 = 
+	"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN";
+    public static final String WEBAPP_DTD_RESOURCE_PATH_23 = 
+	"/javax/servlet/resources/web-app_2_3.dtd";
+
+    /**
+     * List of the Public IDs that we cache, and their
+     * associated location. This is used by 
+     * an EntityResolver to return the location of the
+     * cached copy of a DTD.
+     */
+    public static final String[] CACHED_DTD_PUBLIC_IDS = {
+	TAGLIB_DTD_PUBLIC_ID_11,
+	TAGLIB_DTD_PUBLIC_ID_12,
+	WEBAPP_DTD_PUBLIC_ID_22,
+	WEBAPP_DTD_PUBLIC_ID_23,
+    };
+    public static final String[] CACHED_DTD_RESOURCE_PATHS = {
+	TAGLIB_DTD_RESOURCE_PATH_11,
+	TAGLIB_DTD_RESOURCE_PATH_12,
+	WEBAPP_DTD_RESOURCE_PATH_22,
+	WEBAPP_DTD_RESOURCE_PATH_23,
+    };
+    
+    /**
+     * Default URLs to download the pluging for Netscape and IE.
+     */
+    public static final String NS_PLUGIN_URL = 
+        "http://java.sun.com/products/plugin/";
+
+    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";
+
+    /**
+     * Prefix to use for generated temporary variable names
+     */
+    public static final String TEMP_VARIABLE_NAME_PREFIX =
+        "_jspx_temp";
+
+    /**
+     * A replacement char for "\$".
+     * XXX This is a hack to avoid changing EL interpreter to recognize "\$"
+     */
+    public static final char ESC='\u001b';
+    public static final String ESCStr="'\\u001b'";
+}
+

Added: incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/jasper/EmbeddedServletOptions.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/jasper/EmbeddedServletOptions.java?rev=598331&view=auto
==============================================================================
--- incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/jasper/EmbeddedServletOptions.java (added)
+++ incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/jasper/EmbeddedServletOptions.java Mon Nov 26 08:15:43 2007
@@ -0,0 +1,662 @@
+/*
+ * Copyright 1999,2004 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.jasper;
+
+import java.io.File;
+import java.util.Enumeration;
+import java.util.Map;
+import java.util.Properties;
+
+import javax.servlet.ServletConfig;
+import javax.servlet.ServletContext;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.jasper.compiler.JspConfig;
+import org.apache.jasper.compiler.Localizer;
+import org.apache.jasper.compiler.TagPluginManager;
+import org.apache.jasper.compiler.TldLocationsCache;
+import org.apache.jasper.xmlparser.ParserUtils;
+
+/**
+ * A class to hold all init parameters specific to the JSP engine. 
+ *
+ * @author Anil K. Vijendran
+ * @author Hans Bergsten
+ * @author Pierre Delisle
+ */
+public final class EmbeddedServletOptions implements Options {
+    
+    // Logger
+    private Log log = LogFactory.getLog(EmbeddedServletOptions.class);
+    
+    private Properties settings = new Properties();
+    
+    /**
+     * Is Jasper being used in development mode?
+     */
+    private boolean development = true;
+    
+    /**
+     * Should Ant fork its java compiles of JSP pages.
+     */
+    public boolean fork = true;
+    
+    /**
+     * Do you want to keep the generated Java files around?
+     */
+    private boolean keepGenerated = true;
+    
+    /**
+     * Should white spaces between directives or actions be trimmed?
+     */
+    private boolean trimSpaces = false;
+    
+    /**
+     * Determines whether tag handler pooling is enabled.
+     */
+    private boolean isPoolingEnabled = true;
+    
+    /**
+     * Do you want support for "mapped" files? This will generate
+     * servlet that has a print statement per line of the JSP file.
+     * This seems like a really nice feature to have for debugging.
+     */
+    private boolean mappedFile = true;
+    
+    /**
+     * Do you want stack traces and such displayed in the client's
+     * browser? If this is false, such messages go to the standard
+     * error or a log file if the standard error is redirected. 
+     */
+    private boolean sendErrorToClient = false;
+    
+    /**
+     * Do we want to include debugging information in the class file?
+     */
+    private boolean classDebugInfo = true;
+    
+    /**
+     * Background compile thread check interval in seconds.
+     */
+    private int checkInterval = 0;
+    
+    /**
+     * Is the generation of SMAP info for JSR45 debuggin suppressed?
+     */
+    private boolean isSmapSuppressed = false;
+    
+    /**
+     * Should SMAP info for JSR45 debugging be dumped to a file?
+     */
+    private boolean isSmapDumped = false;
+    
+    /**
+     * Are Text strings to be generated as char arrays?
+     */
+    private boolean genStringAsCharArray = false;
+    
+    private boolean errorOnUseBeanInvalidClassAttribute = true;
+    
+    /**
+     * I want to see my generated servlets. Which directory are they
+     * in?
+     */
+    private String scratchDir;
+    
+    /**
+     * Need to have this as is for versions 4 and 5 of IE. Can be set from
+     * the initParams so if it changes in the future all that is needed is
+     * to have a jsp initParam of type ieClassId="<value>"
+     */
+    private String ieClassId = "clsid:8AD9C840-044E-11D1-B3E9-00805F499D93";
+    
+    /**
+     * What classpath should I use while compiling generated servlets?
+     */
+    private String classpath = null;
+    
+    /**
+     * Compiler to use.
+     */
+    private String compiler = null;
+    
+    /**
+     * Compiler target VM.
+     */
+    private String compilerTargetVM = "1.5";
+    
+    /**
+     * The compiler source VM.
+     */
+    private String compilerSourceVM = "1.5";
+    
+    /**
+     * Cache for the TLD locations
+     */
+    private TldLocationsCache tldLocationsCache = null;
+    
+    /**
+     * Jsp config information
+     */
+    private JspConfig jspConfig = null;
+    
+    /**
+     * TagPluginManager
+     */
+    private TagPluginManager tagPluginManager = null;
+    
+    /**
+     * Java platform encoding to generate the JSP
+     * page servlet.
+     */
+    private String javaEncoding = "UTF8";
+    
+    /**
+     * Modification test interval.
+     */
+    private int modificationTestInterval = 4;
+    
+    /**
+     * Is generation of X-Powered-By response header enabled/disabled?
+     */
+    private boolean xpoweredBy;
+    
+    public String getProperty(String name ) {
+        return settings.getProperty( name );
+    }
+    
+    public void setProperty(String name, String value ) {
+        if (name != null && value != null){ 
+            settings.setProperty( name, value );
+        }
+    }
+    
+    /**
+     * Are we keeping generated code around?
+     */
+    public boolean getKeepGenerated() {
+        return keepGenerated;
+    }
+    
+    /**
+     * Should white spaces between directives or actions be trimmed?
+     */
+    public boolean getTrimSpaces() {
+        return trimSpaces;
+    }
+    
+    public boolean isPoolingEnabled() {
+        return isPoolingEnabled;
+    }
+    
+    /**
+     * Are we supporting HTML mapped servlets?
+     */
+    public boolean getMappedFile() {
+        return mappedFile;
+    }
+    
+    /**
+     * Should errors be sent to client or thrown into stderr?
+     */
+    public boolean getSendErrorToClient() {
+        return sendErrorToClient;
+    }
+    
+    /**
+     * Should class files be compiled with debug information?
+     */
+    public boolean getClassDebugInfo() {
+        return classDebugInfo;
+    }
+    
+    /**
+     * Background JSP compile thread check intervall
+     */
+    public int getCheckInterval() {
+        return checkInterval;
+    }
+    
+    /**
+     * Modification test interval.
+     */
+    public int getModificationTestInterval() {
+        return modificationTestInterval;
+    }
+    
+    /**
+     * Is Jasper being used in development mode?
+     */
+    public boolean getDevelopment() {
+        return development;
+    }
+    
+    /**
+     * Is the generation of SMAP info for JSR45 debuggin suppressed?
+     */
+    public boolean isSmapSuppressed() {
+        return isSmapSuppressed;
+    }
+    
+    /**
+     * Should SMAP info for JSR45 debugging be dumped to a file?
+     */
+    public boolean isSmapDumped() {
+        return isSmapDumped;
+    }
+    
+    /**
+     * Are Text strings to be generated as char arrays?
+     */
+    public boolean genStringAsCharArray() {
+        return this.genStringAsCharArray;
+    }
+    
+    /**
+     * Class ID for use in the plugin tag when the browser is IE. 
+     */
+    public String getIeClassId() {
+        return ieClassId;
+    }
+    
+    /**
+     * What is my scratch dir?
+     */
+    public String getScratchDir() {
+        return scratchDir;
+    }
+    
+    /**
+     * What classpath should I use while compiling the servlets
+     * generated from JSP files?
+     */
+    public String getClassPath() {
+        return classpath;
+    }
+    
+    /**
+     * Return <code>null</code> to force use of the <code>JasperLoader</code>.
+     */
+    public ClassLoader getJspClassLoader() {
+        return null;
+    }
+    
+    /**
+     * Is generation of X-Powered-By response header enabled/disabled?
+     */
+    public boolean isXpoweredBy() {
+        return xpoweredBy;
+    }
+    
+    /**
+     * Compiler to use.
+     */
+    public String getCompiler() {
+        return compiler;
+    }
+    
+    /**
+     * @see Options#getCompilerTargetVM
+     */
+    public String getCompilerTargetVM() {
+        return compilerTargetVM;
+    }
+    
+    /**
+     * @see Options#getCompilerSourceVM
+     */
+    public String getCompilerSourceVM() {
+        return compilerSourceVM;
+    }
+    
+    public boolean getErrorOnUseBeanInvalidClassAttribute() {
+        return errorOnUseBeanInvalidClassAttribute;
+    }
+    
+    public void setErrorOnUseBeanInvalidClassAttribute(boolean b) {
+        errorOnUseBeanInvalidClassAttribute = b;
+    }
+    
+    public TldLocationsCache getTldLocationsCache() {
+        return tldLocationsCache;
+    }
+    
+    public void setTldLocationsCache( TldLocationsCache tldC ) {
+        tldLocationsCache = tldC;
+    }
+    
+    public String getJavaEncoding() {
+        return javaEncoding;
+    }
+    
+    public boolean getFork() {
+        return fork;
+    }
+    
+    public JspConfig getJspConfig() {
+        return jspConfig;
+    }
+    
+    public TagPluginManager getTagPluginManager() {
+        return tagPluginManager;
+    }
+    
+    public boolean isCaching() {
+        return false;
+    }
+    
+    public Map getCache() {
+        return null;
+    }
+
+    /**
+     * Create an EmbeddedServletOptions object using data available from
+     * ServletConfig and ServletContext. 
+     */
+    public EmbeddedServletOptions(ServletConfig config,
+            ServletContext context) {
+        
+        // JVM version numbers
+        try {
+            if (Float.parseFloat(System.getProperty("java.specification.version")) > 1.4) {
+                compilerSourceVM = compilerTargetVM = "1.5";
+            } else {
+                compilerSourceVM = compilerTargetVM = "1.4";
+            }
+        } catch (NumberFormatException e) {
+            // Ignore
+        }
+        
+        Enumeration enumeration=config.getInitParameterNames();
+        while( enumeration.hasMoreElements() ) {
+            String k=(String)enumeration.nextElement();
+            String v=config.getInitParameter( k );
+            setProperty( k, v);
+        }
+        
+        // quick hack
+        String validating=config.getInitParameter( "validating");
+        if( "false".equals( validating )) ParserUtils.validating=false;
+        
+        String keepgen = config.getInitParameter("keepgenerated");
+        if (keepgen != null) {
+            if (keepgen.equalsIgnoreCase("true")) {
+                this.keepGenerated = true;
+            } else if (keepgen.equalsIgnoreCase("false")) {
+                this.keepGenerated = false;
+            } else {
+                if (log.isWarnEnabled()) {
+                    log.warn(Localizer.getMessage("jsp.warning.keepgen"));
+                }
+            }
+        }
+        
+        
+        String trimsp = config.getInitParameter("trimSpaces"); 
+        if (trimsp != null) {
+            if (trimsp.equalsIgnoreCase("true")) {
+                trimSpaces = true;
+            } else if (trimsp.equalsIgnoreCase("false")) {
+                trimSpaces = false;
+            } else {
+                if (log.isWarnEnabled()) {
+                    log.warn(Localizer.getMessage("jsp.warning.trimspaces"));
+                }
+            }
+        }
+        
+        this.isPoolingEnabled = true;
+        String poolingEnabledParam
+        = config.getInitParameter("enablePooling"); 
+        if (poolingEnabledParam != null
+                && !poolingEnabledParam.equalsIgnoreCase("true")) {
+            if (poolingEnabledParam.equalsIgnoreCase("false")) {
+                this.isPoolingEnabled = false;
+            } else {
+                if (log.isWarnEnabled()) {
+                    log.warn(Localizer.getMessage("jsp.warning.enablePooling"));
+                }		       	   
+            }
+        }
+        
+        String mapFile = config.getInitParameter("mappedfile"); 
+        if (mapFile != null) {
+            if (mapFile.equalsIgnoreCase("true")) {
+                this.mappedFile = true;
+            } else if (mapFile.equalsIgnoreCase("false")) {
+                this.mappedFile = false;
+            } else {
+                if (log.isWarnEnabled()) {
+                    log.warn(Localizer.getMessage("jsp.warning.mappedFile"));
+                }
+            }
+        }
+        
+        String senderr = config.getInitParameter("sendErrToClient");
+        if (senderr != null) {
+            if (senderr.equalsIgnoreCase("true")) {
+                this.sendErrorToClient = true;
+            } else if (senderr.equalsIgnoreCase("false")) {
+                this.sendErrorToClient = false;
+            } else {
+                if (log.isWarnEnabled()) {
+                    log.warn(Localizer.getMessage("jsp.warning.sendErrToClient"));
+                }
+            }
+        }
+        
+        String debugInfo = config.getInitParameter("classdebuginfo");
+        if (debugInfo != null) {
+            if (debugInfo.equalsIgnoreCase("true")) {
+                this.classDebugInfo  = true;
+            } else if (debugInfo.equalsIgnoreCase("false")) {
+                this.classDebugInfo  = false;
+            } else {
+                if (log.isWarnEnabled()) {
+                    log.warn(Localizer.getMessage("jsp.warning.classDebugInfo"));
+                }
+            }
+        }
+        
+        String checkInterval = config.getInitParameter("checkInterval");
+        if (checkInterval != null) {
+            try {
+                this.checkInterval = Integer.parseInt(checkInterval);
+                if (this.checkInterval == 0) {
+                    this.checkInterval = 300;
+                    if (log.isWarnEnabled()) {
+                        log.warn(Localizer.getMessage("jsp.warning.checkInterval"));
+                    }
+                }
+            } catch(NumberFormatException ex) {
+                if (log.isWarnEnabled()) {
+                    log.warn(Localizer.getMessage("jsp.warning.checkInterval"));
+                }
+            }
+        }
+        
+        String modificationTestInterval = config.getInitParameter("modificationTestInterval");
+        if (modificationTestInterval != null) {
+            try {
+                this.modificationTestInterval = Integer.parseInt(modificationTestInterval);
+            } catch(NumberFormatException ex) {
+                if (log.isWarnEnabled()) {
+                    log.warn(Localizer.getMessage("jsp.warning.modificationTestInterval"));
+                }
+            }
+        }
+        
+        String development = config.getInitParameter("development");
+        if (development != null) {
+            if (development.equalsIgnoreCase("true")) {
+                this.development = true;
+            } else if (development.equalsIgnoreCase("false")) {
+                this.development = false;
+            } else {
+                if (log.isWarnEnabled()) {
+                    log.warn(Localizer.getMessage("jsp.warning.development"));
+                }
+            }
+        }
+        
+        String suppressSmap = config.getInitParameter("suppressSmap");
+        if (suppressSmap != null) {
+            if (suppressSmap.equalsIgnoreCase("true")) {
+                isSmapSuppressed = true;
+            } else if (suppressSmap.equalsIgnoreCase("false")) {
+                isSmapSuppressed = false;
+            } else {
+                if (log.isWarnEnabled()) {
+                    log.warn(Localizer.getMessage("jsp.warning.suppressSmap"));
+                }
+            }
+        }
+        
+        String dumpSmap = config.getInitParameter("dumpSmap");
+        if (dumpSmap != null) {
+            if (dumpSmap.equalsIgnoreCase("true")) {
+                isSmapDumped = true;
+            } else if (dumpSmap.equalsIgnoreCase("false")) {
+                isSmapDumped = false;
+            } else {
+                if (log.isWarnEnabled()) {
+                    log.warn(Localizer.getMessage("jsp.warning.dumpSmap"));
+                }
+            }
+        }
+        
+        String genCharArray = config.getInitParameter("genStrAsCharArray");
+        if (genCharArray != null) {
+            if (genCharArray.equalsIgnoreCase("true")) {
+                genStringAsCharArray = true;
+            } else if (genCharArray.equalsIgnoreCase("false")) {
+                genStringAsCharArray = false;
+            } else {
+                if (log.isWarnEnabled()) {
+                    log.warn(Localizer.getMessage("jsp.warning.genchararray"));
+                }
+            }
+        }
+        
+        String errBeanClass =
+            config.getInitParameter("errorOnUseBeanInvalidClassAttribute");
+        if (errBeanClass != null) {
+            if (errBeanClass.equalsIgnoreCase("true")) {
+                errorOnUseBeanInvalidClassAttribute = true;
+            } else if (errBeanClass.equalsIgnoreCase("false")) {
+                errorOnUseBeanInvalidClassAttribute = false;
+            } else {
+                if (log.isWarnEnabled()) {
+                    log.warn(Localizer.getMessage("jsp.warning.errBean"));
+                }
+            }
+        }
+        
+        String ieClassId = config.getInitParameter("ieClassId");
+        if (ieClassId != null)
+            this.ieClassId = ieClassId;
+        
+        String classpath = config.getInitParameter("classpath");
+        if (classpath != null)
+            this.classpath = classpath;
+        
+        /*
+         * scratchdir
+         */
+        File scratchDir;
+        String dir = config.getInitParameter("scratchdir"); 
+        if (dir != null) {
+            scratchDir = new File(dir);
+        } else {
+            // First try the Servlet 2.2 javax.servlet.context.tempdir property
+            scratchDir = (File) context.getAttribute(Constants.TMP_DIR);
+            if (scratchDir == null) {
+                // Not running in a Servlet 2.2 container.
+                // Try to get the JDK 1.2 java.io.tmpdir property
+                dir = System.getProperty("java.io.tmpdir");
+                if (dir != null)
+                    scratchDir = new File(dir);
+            }
+        }      
+        if (this.scratchDir == null) {
+            log.fatal(Localizer.getMessage("jsp.error.no.scratch.dir"));
+            return;
+        }
+        
+        if (!(scratchDir.exists() && scratchDir.canRead() &&
+                scratchDir.canWrite() && scratchDir.isDirectory()))
+            log.fatal(Localizer.getMessage("jsp.error.bad.scratch.dir",
+                    scratchDir.getAbsolutePath()));
+        
+        this.scratchDir = scratchDir.getAbsolutePath();
+        this.compiler = config.getInitParameter("compiler");
+        
+        String compilerTargetVM = config.getInitParameter("compilerTargetVM");
+        if(compilerTargetVM != null) {
+            this.compilerTargetVM = compilerTargetVM;
+        }
+        
+        String compilerSourceVM = config.getInitParameter("compilerSourceVM");
+        if(compilerSourceVM != null) {
+            this.compilerSourceVM = compilerSourceVM;
+        }
+        
+        String javaEncoding = config.getInitParameter("javaEncoding");
+        if (javaEncoding != null) {
+            this.javaEncoding = javaEncoding;
+        }
+        
+        String fork = config.getInitParameter("fork");
+        if (fork != null) {
+            if (fork.equalsIgnoreCase("true")) {
+                this.fork = true;
+            } else if (fork.equalsIgnoreCase("false")) {
+                this.fork = false;
+            } else {
+                if (log.isWarnEnabled()) {
+                    log.warn(Localizer.getMessage("jsp.warning.fork"));
+                }
+            }
+        }
+        
+        String xpoweredBy = config.getInitParameter("xpoweredBy"); 
+        if (xpoweredBy != null) {
+            if (xpoweredBy.equalsIgnoreCase("true")) {
+                this.xpoweredBy = true;
+            } else if (xpoweredBy.equalsIgnoreCase("false")) {
+                this.xpoweredBy = false;
+            } else {
+                if (log.isWarnEnabled()) {
+                    log.warn(Localizer.getMessage("jsp.warning.xpoweredBy"));
+                }
+            }
+        }
+        
+        // Setup the global Tag Libraries location cache for this
+        // web-application.
+        tldLocationsCache = new TldLocationsCache(context);
+        
+        // Setup the jsp config info for this web app.
+        jspConfig = new JspConfig(context);
+        
+        // Create a Tag plugin instance
+        tagPluginManager = new TagPluginManager(context);
+    }
+    
+}
+

Added: incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/jasper/JasperException.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/jasper/JasperException.java?rev=598331&view=auto
==============================================================================
--- incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/jasper/JasperException.java (added)
+++ incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/jasper/JasperException.java Mon Nov 26 08:15:43 2007
@@ -0,0 +1,45 @@
+/*
+ * Copyright 1999,2004 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.jasper;
+
+/**
+ * Base class for all exceptions generated by the JSP engine. Makes it
+ * convienient to catch just this at the top-level. 
+ *
+ * @author Anil K. Vijendran
+ */
+public class JasperException extends javax.servlet.ServletException {
+    
+    public JasperException(String reason) {
+	super(reason);
+    }
+
+    /**
+     * Creates a JasperException with the embedded exception and the reason for
+     * throwing a JasperException
+     */
+    public JasperException (String reason, Throwable exception) {
+   	super(reason, exception);
+    }
+
+    /**
+     * Creates a JasperException with the embedded exception
+     */
+    public JasperException (Throwable exception) {
+   	super(exception);
+    }
+}

Added: incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/jasper/JspCompilationContext.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/jasper/JspCompilationContext.java?rev=598331&view=auto
==============================================================================
--- incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/jasper/JspCompilationContext.java (added)
+++ incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/jasper/JspCompilationContext.java Mon Nov 26 08:15:43 2007
@@ -0,0 +1,749 @@
+/*
+ * Copyright 1999,2004 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.jasper;
+
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.net.URLClassLoader;
+import java.util.Hashtable;
+import java.util.Set;
+
+import javax.servlet.ServletContext;
+import javax.servlet.jsp.tagext.TagInfo;
+
+import org.apache.jasper.compiler.Compiler;
+import org.apache.jasper.compiler.JspRuntimeContext;
+import org.apache.jasper.compiler.JspUtil;
+import org.apache.jasper.compiler.Localizer;
+import org.apache.jasper.compiler.ServletWriter;
+import org.apache.jasper.servlet.JasperLoader;
+import org.apache.jasper.servlet.JspServletWrapper;
+
+/**
+ * A place holder for various things that are used through out the JSP
+ * engine. This is a per-request/per-context data structure. Some of
+ * the instance variables are set at different points.
+ *
+ * Most of the path-related stuff is here - mangling names, versions, dirs,
+ * loading resources and dealing with uris. 
+ *
+ * @author Anil K. Vijendran
+ * @author Harish Prabandham
+ * @author Pierre Delisle
+ * @author Costin Manolache
+ * @author Kin-man Chung
+ */
+public class JspCompilationContext {
+
+    protected org.apache.commons.logging.Log log =
+        org.apache.commons.logging.LogFactory.getLog(JspCompilationContext.class);
+
+    private Hashtable tagFileJarUrls;
+    private boolean isPackagedTagFile;
+
+    private String className;
+    private String jspUri;
+    private boolean isErrPage;
+    private String basePackageName;
+    private String derivedPackageName;
+    private String servletJavaFileName;
+    private String javaPath;
+    private String classFileName;
+    private String contentType;
+    private ServletWriter writer;
+    private Options options;
+    private JspServletWrapper jsw;
+    private Compiler jspCompiler;
+    private String classPath;
+
+    private String baseURI;
+    private String baseOutputDir;
+    private String outputDir;
+    private ServletContext context;
+    private ClassLoader loader;
+
+    private JspRuntimeContext rctxt;
+
+    private int removed = 0;
+
+    private ClassLoader jspLoader;
+    private URL baseUrl;
+    private Class servletClass;
+
+    private boolean isTagFile;
+    private boolean protoTypeMode;
+    private TagInfo tagInfo;
+    private URL tagFileJarUrl;
+    
+    // jspURI _must_ be relative to the context
+    public JspCompilationContext(String jspUri,
+                                 boolean isErrPage,
+                                 Options options,
+                                 ServletContext context,
+                                 JspServletWrapper jsw,
+                                 JspRuntimeContext rctxt) {
+
+        this.jspUri = canonicalURI(jspUri);
+        this.isErrPage = isErrPage;
+        this.options = options;
+        this.jsw = jsw;
+        this.context = context;
+
+        this.baseURI = jspUri.substring(0, jspUri.lastIndexOf('/') + 1);
+        // hack fix for resolveRelativeURI
+        if (baseURI == null) {
+            baseURI = "/";
+        } else if (baseURI.charAt(0) != '/') {
+            // strip the basde slash since it will be combined with the
+            // uriBase to generate a file
+            baseURI = "/" + baseURI;
+        }
+        if (baseURI.charAt(baseURI.length() - 1) != '/') {
+            baseURI += '/';
+        }
+
+        this.rctxt = rctxt;
+        this.tagFileJarUrls = new Hashtable();
+        this.basePackageName = Constants.JSP_PACKAGE_NAME;
+    }
+
+    public JspCompilationContext(String tagfile,
+                                 TagInfo tagInfo, 
+                                 Options options,
+                                 ServletContext context,
+                                 JspServletWrapper jsw,
+                                 JspRuntimeContext rctxt,
+                                 URL tagFileJarUrl) {
+        this(tagfile, false, options, context, jsw, rctxt);
+        this.isTagFile = true;
+        this.tagInfo = tagInfo;
+        this.tagFileJarUrl = tagFileJarUrl;
+        if (tagFileJarUrl != null) {
+            isPackagedTagFile = true;
+        }
+    }
+
+    /* ==================== Methods to override ==================== */
+    
+    /** ---------- Class path and loader ---------- */
+
+    /**
+     * The classpath that is passed off to the Java compiler. 
+     */
+    public String getClassPath() {
+        if( classPath != null )
+            return classPath;
+        return rctxt.getClassPath();
+    }
+
+    /**
+     * The classpath that is passed off to the Java compiler. 
+     */
+    public void setClassPath(String classPath) {
+        this.classPath = classPath;
+    }
+
+    /**
+     * What class loader to use for loading classes while compiling
+     * this JSP?
+     */
+    public ClassLoader getClassLoader() {
+        if( loader != null )
+            return loader;
+        return rctxt.getParentClassLoader();
+    }
+
+    public void setClassLoader(ClassLoader loader) {
+        this.loader = loader;
+    }
+
+    public ClassLoader getJspLoader() {
+        if( jspLoader == null ) {
+            ClassLoader jspLoader = options.getJspClassLoader();
+            if (jspLoader == null) {
+                jspLoader = new JasperLoader(new URL[] { baseUrl },
+                    getClassLoader(), rctxt.getPermissionCollection(),
+                    rctxt.getCodeSource());
+            }
+            this.jspLoader = jspLoader;
+        }
+        return jspLoader;
+    }
+
+    /** ---------- Input/Output  ---------- */
+    
+    /**
+     * Creates an output stream to the given file
+     * @param fileName The path to the file to write to
+     * @return The OutputStream to the file
+     * @throws IOException If an error occurrs creating the output stream.
+     */
+    public OutputStream getOutputStream(String fileName) throws IOException {
+        return getRuntimeContext().getOutputProvider().getOutputStream(fileName);
+    }
+    
+    /**
+     * Creates an input stream from the given file
+     * @param fileName The path to the file to read from
+     * @return The InputStream from the file
+     * @throws FileNotFoundException If the file cannot be found
+     * @throws IOException If an error occurrs creating the intput stream.
+     */
+    public InputStream getInputStream(String fileName)
+            throws FileNotFoundException, IOException {
+        return getRuntimeContext().getOutputProvider().getInputStream(fileName);
+    }
+    
+    /**
+     * Removes a (generated) file.
+     * @param fileName The path to the file to remove.
+     * @return <code>true</code> if the file has been removed.
+     */
+    public boolean delete(String fileName) {
+        return getRuntimeContext().getOutputProvider().delete(fileName);
+    }
+    
+    /**
+     * Renams then old file to the new file
+     * @return <code>true</code> if the file has been renamed
+     * 
+     */
+    public boolean rename(String oldFileName, String newFileName) {
+        return getRuntimeContext().getOutputProvider().rename(oldFileName, newFileName);
+    }
+    
+    /**
+     * The output directory to generate code into.  The output directory
+     * is make up of the scratch directory, which is provide in Options,
+     * plus the directory derived from the package name.
+     */
+    public String getOutputDir() {
+	if (outputDir == null) {
+	    createOutputDir();
+	}
+
+        return outputDir;
+    }
+
+    /**
+     * Create a "Compiler" object based on some init param data. This
+     * is not done yet. Right now we're just hardcoding the actual
+     * compilers that are created. 
+     */
+    public Compiler createCompiler() throws JasperException {
+        if (jspCompiler != null ) {
+            return jspCompiler;
+        }
+        jspCompiler = null;
+        if (options.getCompiler() == null) {
+            jspCompiler = createCompiler("org.apache.jasper.compiler.JDTCompiler");
+            if (jspCompiler == null) {
+                jspCompiler = createCompiler("org.apache.jasper.compiler.AntCompiler");
+            }
+        } else {
+            jspCompiler = createCompiler("org.apache.jasper.compiler.AntCompiler");
+            if (jspCompiler == null) {
+                jspCompiler = createCompiler("org.apache.jasper.compiler.JDTCompiler");
+            }
+        }
+        if (jspCompiler == null) {
+            throw new IllegalStateException(Localizer.getMessage("jsp.error.compiler"));
+        }
+        jspCompiler.init(this, jsw);
+        return jspCompiler;
+    }
+
+    private Compiler createCompiler(String className) {
+        Compiler compiler = null; 
+        try {
+            compiler = (Compiler) Class.forName(className).newInstance();
+        } catch (Throwable t) {
+            if (log.isDebugEnabled()) {
+                log.debug(Localizer.getMessage("jsp.error.compiler"), t);
+            }
+        }
+        return compiler;
+    }
+    
+    public Compiler getCompiler() {
+        return jspCompiler;
+    }
+
+    /** ---------- Access resources in the webapp ---------- */
+
+    /** 
+     * Get the full value of a URI relative to this compilations context
+     * uses current file as the base.
+     */
+    public String resolveRelativeUri(String uri) {
+        // sometimes we get uri's massaged from File(String), so check for
+        // a root directory deperator char
+        if (uri.startsWith("/") || uri.startsWith(File.separator)) {
+            return uri;
+        } else {
+            return baseURI + uri;
+        }
+    }
+
+    /**
+     * Gets a resource as a stream, relative to the meanings of this
+     * context's implementation.
+     * @return a null if the resource cannot be found or represented 
+     *         as an InputStream.
+     */
+    public java.io.InputStream getResourceAsStream(String res) {
+        return context.getResourceAsStream(canonicalURI(res));
+    }
+
+
+    public URL getResource(String res) throws MalformedURLException {
+        return context.getResource(canonicalURI(res));
+    }
+
+    public Set getResourcePaths(String path) {
+        return context.getResourcePaths(canonicalURI(path));
+    }
+
+    /** 
+     * Gets the actual path of a URI relative to the context of
+     * the compilation.
+     */
+    public String getRealPath(String path) {
+        if (context != null) {
+            return context.getRealPath(path);
+        }
+        return path;
+    }
+
+    /**
+     * Returns the tag-file-name-to-JAR-file map of this compilation unit,
+     * which maps tag file names to the JAR files in which the tag files are
+     * packaged.
+     *
+     * The map is populated when parsing the tag-file elements of the TLDs
+     * of any imported taglibs. 
+     */
+    public Hashtable getTagFileJarUrls() {
+        return this.tagFileJarUrls;
+    }
+
+    /**
+     * Returns the JAR file in which the tag file for which this
+     * JspCompilationContext was created is packaged, or null if this
+     * JspCompilationContext does not correspond to a tag file, or if the
+     * corresponding tag file is not packaged in a JAR.
+     */
+    public URL getTagFileJarUrl() {
+        return this.tagFileJarUrl;
+    }
+
+    /* ==================== Common implementation ==================== */
+
+    /**
+     * Just the class name (does not include package name) of the
+     * generated class. 
+     */
+    public String getServletClassName() {
+
+        if (className != null) {
+            return className;
+        }
+
+        if (isTagFile) {
+            className = tagInfo.getTagClassName();
+            int lastIndex = className.lastIndexOf('.');
+            if (lastIndex != -1) {
+                className = className.substring(lastIndex + 1);
+            }
+        } else {
+            int iSep = jspUri.lastIndexOf('/') + 1;
+            className = JspUtil.makeJavaIdentifier(jspUri.substring(iSep));
+        }
+        return className;
+    }
+
+    public void setServletClassName(String className) {
+        this.className = className;
+    }
+    
+    /**
+     * Path of the JSP URI. Note that this is not a file name. This is
+     * the context rooted URI of the JSP file. 
+     */
+    public String getJspFile() {
+        return jspUri;
+    }
+
+    /**
+     * Are we processing something that has been declared as an
+     * errorpage? 
+     */
+    public boolean isErrorPage() {
+        return isErrPage;
+    }
+
+    public void setErrorPage(boolean isErrPage) {
+        this.isErrPage = isErrPage;
+    }
+
+    public boolean isTagFile() {
+        return isTagFile;
+    }
+
+    public TagInfo getTagInfo() {
+        return tagInfo;
+    }
+
+    public void setTagInfo(TagInfo tagi) {
+        tagInfo = tagi;
+    }
+
+    /**
+     * True if we are compiling a tag file in prototype mode.
+     * ie we only generate codes with class for the tag handler with empty
+     * method bodies.
+     */
+    public boolean isPrototypeMode() {
+        return protoTypeMode;
+    }
+
+    public void setPrototypeMode(boolean pm) {
+        protoTypeMode = pm;
+    }
+
+    /**
+     * Package name for the generated class is make up of the base package
+     * name, which is user settable, and the derived package name.  The
+     * derived package name directly mirrors the file heirachy of the JSP page.
+     */
+    public String getServletPackageName() {
+        if (isTagFile()) {
+            String className = tagInfo.getTagClassName();
+            int lastIndex = className.lastIndexOf('.');
+            String pkgName = "";
+            if (lastIndex != -1) {
+                pkgName = className.substring(0, lastIndex);
+            }
+            return pkgName;
+        } else if (basePackageName == null || basePackageName.length() == 0) {
+            return getDerivedPackageName();
+        } else {
+            String dPackageName = getDerivedPackageName();
+            if (dPackageName.length() == 0) {
+                return basePackageName;
+            }
+            return basePackageName + '.' + getDerivedPackageName();
+        }
+    }
+
+    private String getDerivedPackageName() {
+        if (derivedPackageName == null) {
+            int iSep = jspUri.lastIndexOf('/');
+            derivedPackageName = (iSep > 0) ?
+                    JspUtil.makeJavaPackage(jspUri.substring(1,iSep)) : "";
+        }
+        return derivedPackageName;
+    }
+	    
+    /**
+     * The package name into which the servlet class is generated.
+     */
+    public void setServletPackageName(String servletPackageName) {
+        this.basePackageName = servletPackageName;
+    }
+
+    /**
+     * Full path name of the Java file into which the servlet is being
+     * generated. 
+     */
+    public String getServletJavaFileName() {
+
+        if (servletJavaFileName == null) {
+            servletJavaFileName =
+		getOutputDir() + getServletClassName() + ".java";
+        } else {
+            // Make sure output dir exists
+            makeOutputDir();
+        }
+        return servletJavaFileName;
+    }
+
+    public void setServletJavaFileName(String servletJavaFileName) {
+        this.servletJavaFileName = servletJavaFileName;
+    }
+
+    /**
+     * Get hold of the Options object for this context. 
+     */
+    public Options getOptions() {
+        return options;
+    }
+
+    public ServletContext getServletContext() {
+        return context;
+    }
+
+    public JspRuntimeContext getRuntimeContext() {
+        return rctxt;
+    }
+
+    /**
+     * Path of the Java file relative to the work directory.
+     */
+    public String getJavaPath() {
+
+        if (javaPath != null) {
+            return javaPath;
+        }
+
+        if (isTagFile()) {
+	    String tagName = tagInfo.getTagClassName();
+            javaPath = tagName.replace('.', '/') + ".java";
+        } else {
+            javaPath = getServletPackageName().replace('.', '/') + '/' +
+                       getServletClassName() + ".java";
+	}
+        return javaPath;
+    }
+
+    public String getClassFileName() {
+
+        if (classFileName == null) {
+            classFileName = getOutputDir() + getServletClassName() + ".class";
+        } else {
+            // Make sure output dir exists
+            makeOutputDir();
+        }
+        return classFileName;
+    }
+
+    /**
+     * Get the content type of this JSP.
+     *
+     * Content type includes content type and encoding.
+     */
+    public String getContentType() {
+        return contentType;
+    }
+
+    public void setContentType(String contentType) {
+        this.contentType = contentType;
+    }
+
+    /**
+     * Where is the servlet being generated?
+     */
+    public ServletWriter getWriter() {
+        return writer;
+    }
+
+    public void setWriter(ServletWriter writer) {
+        this.writer = writer;
+    }
+
+    /**
+     * Gets the 'location' of the TLD associated with the given taglib 'uri'.
+     * 
+     * @return An array of two Strings: The first element denotes the real
+     * path to the TLD. If the path to the TLD points to a jar file, then the
+     * second element denotes the name of the TLD entry in the jar file.
+     * Returns null if the given uri is not associated with any tag library
+     * 'exposed' in the web application.
+     */
+    public String[] getTldLocation(String uri) throws JasperException {
+        String[] location = 
+            getOptions().getTldLocationsCache().getLocation(uri);
+        return location;
+    }
+
+    /**
+     * Are we keeping generated code around?
+     */
+    public boolean keepGenerated() {
+        return getOptions().getKeepGenerated();
+    }
+
+    // ==================== Removal ==================== 
+
+    public void incrementRemoved() {
+        if (removed > 1) {
+            jspCompiler.removeGeneratedFiles();
+            if( rctxt != null )
+                rctxt.removeWrapper(jspUri);
+        }
+        removed++;
+    }
+
+    public boolean isRemoved() {
+        if (removed > 1 ) {
+            return true;
+        }
+        return false;
+    }
+
+    // ==================== Compile and reload ====================
+    
+    public void compile() throws JasperException, FileNotFoundException {
+        createCompiler();
+        if (isPackagedTagFile || jspCompiler.isOutDated()) {
+            try {
+                jspLoader = null;
+                jspCompiler.compile();
+                jsw.setReload(true);
+                jsw.setCompilationException(null);
+            } catch (JasperException ex) {
+                // Cache compilation exception
+                jsw.setCompilationException(ex);
+                throw ex;
+            } catch (Exception ex) {
+                ex.printStackTrace();
+                JasperException je = new JasperException(
+                            Localizer.getMessage("jsp.error.unable.compile"),
+                            ex);
+                // Cache compilation exception
+                jsw.setCompilationException(je);
+                throw je;
+            }
+        }
+    }
+
+    // ==================== Manipulating the class ====================
+
+    public Class load() 
+        throws JasperException, FileNotFoundException
+    {
+        try {
+            getJspLoader();
+            
+            String name;
+            if (isTagFile()) {
+                name = tagInfo.getTagClassName();
+            } else {
+                name = getServletPackageName() + "." + getServletClassName();
+            }
+            servletClass = jspLoader.loadClass(name);
+        } catch (ClassNotFoundException cex) {
+            throw new JasperException(Localizer.getMessage("jsp.error.unable.load"),
+                                      cex);
+        } catch (Exception ex) {
+            throw new JasperException(Localizer.getMessage("jsp.error.unable.compile"),
+                                      ex);
+        }
+        removed = 0;
+        return servletClass;
+    }
+
+    // ==================== Private methods ==================== 
+
+    static Object outputDirLock = new Object();
+
+    private void makeOutputDir() {
+        synchronized(outputDirLock) {
+            getRuntimeContext().getOutputProvider().mkdirs(outputDir);
+        }
+    }
+
+    private void createOutputDir() {
+        String path = null;
+        if (isTagFile()) {
+	    String tagName = tagInfo.getTagClassName();
+            path = tagName.replace('.', '/');
+	    path = path.substring(0, path.lastIndexOf('/'));
+        } else {
+            path = getServletPackageName().replace('.', '/');
+	}
+
+        try {
+            // Append servlet or tag handler path to scratch dir
+            baseUrl = new File(options.getScratchDir()).toURI().toURL();
+            outputDir = options.getScratchDir() + File.separator + path + File.separator;
+            makeOutputDir();
+        } catch (Exception e) {
+            throw new IllegalStateException("No output directory: " +
+                                            e.getMessage());
+        }
+    }
+    
+    private static final boolean isPathSeparator(char c) {
+       return (c == '/' || c == '\\');
+    }
+
+    private static final String canonicalURI(String s) {
+       if (s == null) return null;
+       StringBuffer result = new StringBuffer();
+       final int len = s.length();
+       int pos = 0;
+       while (pos < len) {
+           char c = s.charAt(pos);
+           if ( isPathSeparator(c) ) {
+               /*
+                * multiple path separators.
+                * 'foo///bar' -> 'foo/bar'
+                */
+               while (pos+1 < len && isPathSeparator(s.charAt(pos+1))) {
+                   ++pos;
+               }
+
+               if (pos+1 < len && s.charAt(pos+1) == '.') {
+                   /*
+                    * a single dot at the end of the path - we are done.
+                    */
+                   if (pos+2 >= len) break;
+
+                   switch (s.charAt(pos+2)) {
+                       /*
+                        * self directory in path
+                        * foo/./bar -> foo/bar
+                        */
+                   case '/':
+                   case '\\':
+                       pos += 2;
+                       continue;
+
+                       /*
+                        * two dots in a path: go back one hierarchy.
+                        * foo/bar/../baz -> foo/baz
+                        */
+                   case '.':
+                       // only if we have exactly _two_ dots.
+                       if (pos+3 < len && isPathSeparator(s.charAt(pos+3))) {
+                           pos += 3;
+                           int separatorPos = result.length()-1;
+                           while (separatorPos >= 0 && 
+                                  ! isPathSeparator(result
+                                                    .charAt(separatorPos))) {
+                               --separatorPos;
+                           }
+                           if (separatorPos >= 0)
+                               result.setLength(separatorPos);
+                           continue;
+                       }
+                   }
+               }
+           }
+           result.append(c);
+           ++pos;
+       }
+       return result.toString();
+    }
+}
+

Added: incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/jasper/Options.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/jasper/Options.java?rev=598331&view=auto
==============================================================================
--- incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/jasper/Options.java (added)
+++ incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/jasper/Options.java Mon Nov 26 08:15:43 2007
@@ -0,0 +1,200 @@
+/*
+ * Copyright 1999,2004 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.jasper;
+
+import java.io.File;
+import java.util.Map;
+
+import org.apache.jasper.compiler.JspConfig;
+import org.apache.jasper.compiler.TagPluginManager;
+import org.apache.jasper.compiler.TldLocationsCache;
+
+/**
+ * A class to hold all init parameters specific to the JSP engine. 
+ *
+ * @author Anil K. Vijendran
+ * @author Hans Bergsten
+ * @author Pierre Delisle
+ */
+public interface Options {
+
+    /**
+     * Returns true if Jasper issues a compilation error instead of a runtime
+     * Instantiation error if the class attribute specified in useBean action
+     * is invalid.
+     */
+    public boolean getErrorOnUseBeanInvalidClassAttribute();
+
+    /**
+     * Are we keeping generated code around?
+     */
+    public boolean getKeepGenerated();
+
+    /**
+     * Returns true if tag handler pooling is enabled, false otherwise.
+     */
+    public boolean isPoolingEnabled();
+
+    /**
+     * Are we supporting HTML mapped servlets?
+     */
+    public boolean getMappedFile();
+
+    /**
+     * Should errors be sent to client or thrown into stderr?
+     */
+    public boolean getSendErrorToClient();
+ 
+    /**
+     * Should we include debug information in compiled class?
+     */
+    public boolean getClassDebugInfo();
+
+    /**
+     * Background compile thread check interval in seconds
+     */
+    public int getCheckInterval();
+
+    /**
+     * Is Jasper being used in development mode?
+     */
+    public boolean getDevelopment();
+
+    /**
+     * Is the generation of SMAP info for JSR45 debugging suppressed?
+     */
+    public boolean isSmapSuppressed();
+
+    /**
+     * Indicates whether SMAP info for JSR45 debugging should be dumped to a
+     * file.
+     * Ignored is suppressSmap() is true
+     */
+    public boolean isSmapDumped();
+
+    /**
+     * Should white spaces between directives or actions be trimmed?
+     */
+    public boolean getTrimSpaces();
+
+    /**
+     * Class ID for use in the plugin tag when the browser is IE. 
+     */
+    public String getIeClassId();
+
+    /**
+     * What is my scratch dir?
+     */
+    public String getScratchDir();
+
+    /**
+     * What classpath should I use while compiling the servlets
+     * generated from JSP files?
+     */
+    public String getClassPath();
+    
+    /**
+     * The classloader to use when compiling servlets generated from JSP files
+     * and to load the servlets.
+     * <p>
+     * If this method returns <code>null</code> the
+     * {@link org.apache.jasper.servlet.JasperLoader} class is used.
+     * 
+     * @return The <code>ClassLoader</code> to use for compilation and JSP
+     *      loading or <code>null</code> to use the <code>JasperLoader</code>.
+     */
+    public ClassLoader getJspClassLoader();
+
+    /**
+     * Compiler to use.
+     */
+    public String getCompiler();
+
+    /**
+     * The compiler target VM, e.g. 1.1, 1.2, 1.3, 1.4, or 1.5.
+     */
+    public String getCompilerTargetVM();
+
+    /**
+     * Compiler source VM, e.g. 1.3, 1.4, or 1.5.
+     */
+    public String getCompilerSourceVM();   
+
+    /**
+     * The cache for the location of the TLD's
+     * for the various tag libraries 'exposed'
+     * by the web application.
+     * A tag library is 'exposed' either explicitely in 
+     * web.xml or implicitely via the uri tag in the TLD 
+     * of a taglib deployed in a jar file (WEB-INF/lib).
+     *
+     * @return the instance of the TldLocationsCache
+     * for the web-application.
+     */
+    public TldLocationsCache getTldLocationsCache();
+
+    /**
+     * Java platform encoding to generate the JSP
+     * page servlet.
+     */
+    public String getJavaEncoding();
+
+    /**
+     * boolean flag to tell Ant whether to fork JSP page compilations.
+     */
+    public boolean getFork();
+
+    /**
+     * Obtain JSP configuration informantion specified in web.xml.  
+     */
+    public JspConfig getJspConfig();
+
+    /**
+     * Is generation of X-Powered-By response header enabled/disabled?
+     */
+    public boolean isXpoweredBy();
+
+    /**
+     * Obtain a Tag Plugin Manager
+     */
+    public TagPluginManager getTagPluginManager();
+
+    /**
+     * Are Text strings to be generated as char arrays?
+     */
+    public boolean genStringAsCharArray();
+    
+    /**
+     * Modification test interval.
+     */
+    public int getModificationTestInterval();
+    
+    /**
+     * Is caching enabled (used for precompilation).
+     */
+    public boolean isCaching();
+    
+    /**
+     * The web-application wide cache for the returned TreeNode
+     * by parseXMLDocument in TagLibraryInfoImpl.parseTLD,
+     * if isCaching returns true.
+     * 
+     * @return the Map(String uri, TreeNode tld) instance.
+     */
+    public Map getCache();
+    
+}

Added: incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/jasper/OutputProvider.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/jasper/OutputProvider.java?rev=598331&view=auto
==============================================================================
--- incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/jasper/OutputProvider.java (added)
+++ incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/jasper/OutputProvider.java Mon Nov 26 08:15:43 2007
@@ -0,0 +1,135 @@
+/*
+ * Copyright 2007 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at 
+ * 
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jasper;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+
+/**
+ * The <code>OutputProvider</code> is an interface to provide more control of
+ * sending output from JSP Java and Class generation phases as well as cleaning
+ * up in case of problems.
+ */
+public interface OutputProvider {
+
+    /**
+     * The default output provider, which is based on the OS filesystem
+     */
+    public static final OutputProvider DEFAULT = new OutputProvider() {
+        public OutputStream getOutputStream(String fileName) throws IOException {
+            File file = new File(fileName);
+            file.getParentFile().mkdirs(); // ensure parent path exists
+            return new FileOutputStream(fileName);
+        }
+        public InputStream getInputStream(String fileName)
+                throws FileNotFoundException, IOException {
+            return new FileInputStream(fileName);
+        }
+        public boolean delete(String fileName) {
+            return new File(fileName).delete();
+        }
+        public boolean rename(String oldFileName, String newFileName) {
+            return new File(oldFileName).renameTo(new File(newFileName));
+        }
+        public boolean mkdirs(String path) {
+            return new File(path).mkdirs();
+        }
+        public long lastModified(String path) {
+            File checkFile = new File(path);
+            return (checkFile.exists()) ? checkFile.lastModified() : -1L;
+        }
+    };
+
+    /**
+     * @param fileName The absolute path name of the destination into which to
+     *      write the output. The semantics of this path depends on the
+     *      implementation of this interface.
+     *      
+     * @return an <code>OutputStream</code> into which to write the generated
+     *      output.
+     *      
+     * @throws IOException If the output stream cannot be created for the file.
+     */
+    OutputStream getOutputStream(String fileName) throws IOException;
+    
+    /**
+     * Returns an input stream to a file which has been written through a
+     * stream obtained form {@link #getOutputStream(String)}
+     * 
+     * @param fileName The absolute path name of the source from which to
+     *      read the input. The semantics of this path depends on the
+     *      implementation of this interface.
+     *      
+     * @return an <code>InputStream</code> from which to read the input.
+     * 
+     * @throws FileNotFoundException If the file cannot be found
+     * @throws IOException If any other error occurs.
+     */
+    InputStream getInputStream(String fileName)
+            throws FileNotFoundException, IOException;
+    
+    /**
+     * Remove a generated output.
+     * 
+     * @param fileName The absolute path name of the item to remove. The
+     *      semantics of this path depends on the implementation of this
+     *      interface.
+     *      
+     * @return <code>true</code> if the item could be removed, otherwise
+     *      <code>false</code> is removed. 
+     */
+    boolean delete(String fileName);
+    
+    /**
+     * Renames the the file from the old file to the new file name
+     * @param oldFileName
+     * @param newFileName
+     * @return <code>true</code> if renaming succeeded
+     */
+    boolean rename(String oldFileName, String newFileName);
+    
+    /**
+     * Creates folders (folder like) structures, such that a container for data
+     * is available at the given path.
+     * <p>
+     * In the case of a OS Filesystem implementation, this method would be
+     * implemented by means of <code>new java.io.File(path).mkdirs()</code>.
+     * 
+     * @param path The absolute path of the folder to create.
+     * 
+     * @return <code>true</code> if and only if the folder was created, along
+     *         with all necessary parent directories; <code>false</code>
+     *         otherwise.
+     */
+    boolean mkdirs(String path);
+    
+    /**
+     * Returns the last modification time stamp of the resource (generally a
+     * file) at the given absolute location.
+     * 
+     * @param fileName The absolute path to the file whose last modification
+     *      time stamp is to be returned.
+     *      
+     * @return The last modification time stamp of the resource in milliseconds
+     *      since the epoch or -1 if no resource exists at the given location.
+     */
+    long lastModified(String fileName);
+}

Added: incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/jasper/compiler/BeanRepository.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/jasper/compiler/BeanRepository.java?rev=598331&view=auto
==============================================================================
--- incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/jasper/compiler/BeanRepository.java (added)
+++ incubator/sling/trunk/scripting/jsp/src/main/java/org/apache/jasper/compiler/BeanRepository.java Mon Nov 26 08:15:43 2007
@@ -0,0 +1,114 @@
+/*
+ * Copyright 1999,2004 The Apache Software Foundation.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.jasper.compiler;
+
+
+import java.util.Vector;
+import java.util.Hashtable;
+
+import org.apache.jasper.JasperException;
+
+/**
+ * Repository of {page, request, session, application}-scoped beans 
+ *
+ * @author Mandar Raje
+ */
+class BeanRepository {
+
+    private Vector sessionBeans;
+    private Vector pageBeans;
+    private Vector appBeans;
+    private Vector requestBeans;
+    private Hashtable beanTypes;
+    private ClassLoader loader;
+    private ErrorDispatcher errDispatcher;
+
+    /*
+     * Constructor.
+     */    
+    public BeanRepository(ClassLoader loader, ErrorDispatcher err) {
+
+        this.loader = loader;
+	this.errDispatcher = err;
+
+	sessionBeans = new Vector(11);
+	pageBeans = new Vector(11);
+	appBeans = new Vector(11);
+	requestBeans = new Vector(11);
+	beanTypes = new Hashtable();
+    }
+        
+    public void addBean(Node.UseBean n, String s, String type, String scope)
+	    throws JasperException {
+
+	if (scope == null || scope.equals("page")) {
+	    pageBeans.addElement(s);	
+	} else if (scope.equals("request")) {
+	    requestBeans.addElement(s);
+	} else if (scope.equals("session")) {
+	    sessionBeans.addElement(s);
+	} else if (scope.equals("application")) {
+	    appBeans.addElement(s);
+	} else {
+	    errDispatcher.jspError(n, "jsp.error.usebean.badScope");
+	}
+	
+	putBeanType(s, type);
+    }
+            
+    public Class getBeanType(String bean) throws JasperException {
+	Class clazz = null;
+	try {
+	    clazz = loader.loadClass ((String)beanTypes.get(bean));
+	} catch (ClassNotFoundException ex) {
+	    throw new JasperException (ex);
+	}
+	return clazz;
+    }
+      
+    public boolean checkVariable (String bean) {
+	// XXX Not sure if this is the correct way.
+	// After pageContext is finalised this will change.
+	return (checkPageBean(bean) || checkSessionBean(bean) ||
+		checkRequestBean(bean) || checkApplicationBean(bean));
+    }
+
+
+    private void putBeanType(String bean, String type) {
+	beanTypes.put (bean, type);
+    }
+
+    private boolean checkPageBean (String s) {
+	return pageBeans.contains (s);
+    }
+
+    private boolean checkRequestBean (String s) {
+	return requestBeans.contains (s);
+    }
+
+    private boolean checkSessionBean (String s) {
+	return sessionBeans.contains (s);
+    }
+
+    private boolean checkApplicationBean (String s) {
+	return appBeans.contains (s);
+    }
+
+}
+
+
+
+



Re: svn commit: r598331 [1/22] - in /incubator/sling/trunk/scripting/jsp: ./ src/main/java/org/apache/jasper/ src/main/java/org/apache/jasper/compiler/ src/main/java/org/apache/jasper/compiler/tagplugin/ src/main/java/org/apache/jasper/runtime/ src/main/ja...

Posted by Felix Meschberger <fm...@gmail.com>.
Hi Roy,

Yes, you are right, the only reason, why we have this in our repository
is to hack the output stuff, such that the classes go into the
repository. Unfortunately, there is no proper OOP way of doing this as
part of it is hard coded into Jasper and other parts have not the
correct visibility.

I am as unhappy with this as you are. I am currently considering two
options to fix this:

(1) Not writing the classes to the repository at all. This way, we can
just use plain Jasper with our own CompilationContext. This has the
drawback that removing classes remotely is difficult (it is not required
but very helpfull sometimes).

(2) Copy the classes to the repository after successfull compilation to
the file system. This gives us the support for remote class removal at
the expense of having to copy them.

Regards
Felix

Am Montag, den 26.11.2007, 14:44 -0800 schrieb Roy T. Fielding:
> On Nov 26, 2007, at 8:15 AM, fmeschbe@apache.org wrote:
> > SLING-98 Migrate JSP scripting support
> >   + plus include Jasper Compiler and EL implementation
> 
> Ouch.  Just out of curiosity, why do we need the source of jasper?
> Is it to replace the back-end storage bits with JCR?  Would it be
> possible to use some OOP to override the specific storage classes
> within jasper instead of building the entire tree?  If not, then
> I think we should rename jasper to sling/ssi4j (or something) to
> avoid the library binding clashes.
> 
> ....Roy


Re: svn commit: r598331 [1/22] - in /incubator/sling/trunk/scripting/jsp: ./ src/main/java/org/apache/jasper/ src/main/java/org/apache/jasper/compiler/ src/main/java/org/apache/jasper/compiler/tagplugin/ src/main/java/org/apache/jasper/runtime/ src/main/ja...

Posted by "Roy T. Fielding" <fi...@gbiv.com>.
On Nov 26, 2007, at 8:15 AM, fmeschbe@apache.org wrote:
> SLING-98 Migrate JSP scripting support
>   + plus include Jasper Compiler and EL implementation

Ouch.  Just out of curiosity, why do we need the source of jasper?
Is it to replace the back-end storage bits with JCR?  Would it be
possible to use some OOP to override the specific storage classes
within jasper instead of building the entire tree?  If not, then
I think we should rename jasper to sling/ssi4j (or something) to
avoid the library binding clashes.

....Roy