incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fmesc...@apache.org
Subject svn commit: r578588 - in /incubator/sling/trunk: scripting-core/src/main/java/org/apache/sling/scripting/ scripting-jsp/src/main/java/org/apache/sling/scripting/jsp/
Date Sun, 23 Sep 2007 17:36:35 GMT
Author: fmeschbe
Date: Sun Sep 23 10:36:33 2007
New Revision: 578588

URL: http://svn.apache.org/viewvc?rev=578588&view=rev
Log:
SLING-19 stackoverflow trying to run jsp scripting

Removed:
    incubator/sling/trunk/scripting-core/src/main/java/org/apache/sling/scripting/HttpServletAdapter.java
Modified:
    incubator/sling/trunk/scripting-core/src/main/java/org/apache/sling/scripting/Util.java
    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/JspServletWrapperAdapter.java

Modified: incubator/sling/trunk/scripting-core/src/main/java/org/apache/sling/scripting/Util.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/scripting-core/src/main/java/org/apache/sling/scripting/Util.java?rev=578588&r1=578587&r2=578588&view=diff
==============================================================================
--- incubator/sling/trunk/scripting-core/src/main/java/org/apache/sling/scripting/Util.java
(original)
+++ incubator/sling/trunk/scripting-core/src/main/java/org/apache/sling/scripting/Util.java
Sun Sep 23 10:36:33 2007
@@ -21,8 +21,6 @@
 public class Util {
 
     public static final String ATTR_COMPONENT = "org.apache.sling.scripting.component";
-    public static final String ATTR_RENDER_REQUEST = "org.apache.sling.scripting.render_request";
-    public static final String ATTR_RENDER_RESPONSE = "org.apache.sling.scripting.render_response";
 
     public static Object replaceAttribute(ComponentRequest request, String attrName, Object
value) {
         // get the old value

Modified: incubator/sling/trunk/scripting-jsp/src/main/java/org/apache/sling/scripting/jsp/JspScriptHandler.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/scripting-jsp/src/main/java/org/apache/sling/scripting/jsp/JspScriptHandler.java?rev=578588&r1=578587&r2=578588&view=diff
==============================================================================
--- incubator/sling/trunk/scripting-jsp/src/main/java/org/apache/sling/scripting/jsp/JspScriptHandler.java
(original)
+++ incubator/sling/trunk/scripting-jsp/src/main/java/org/apache/sling/scripting/jsp/JspScriptHandler.java
Sun Sep 23 10:36:33 2007
@@ -140,7 +140,7 @@
 
     public ComponentRenderer getComponentRenderer(Component component,
             String scriptName) {
-        return this.getJspWrapperAdapter(component, scriptName).getServletAdapter();
+        return getJspWrapperAdapter(component, scriptName);
     }
 
     private JspServletWrapperAdapter getJspWrapperAdapter(Component component,

Modified: incubator/sling/trunk/scripting-jsp/src/main/java/org/apache/sling/scripting/jsp/JspServletWrapperAdapter.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/scripting-jsp/src/main/java/org/apache/sling/scripting/jsp/JspServletWrapperAdapter.java?rev=578588&r1=578587&r2=578588&view=diff
==============================================================================
--- incubator/sling/trunk/scripting-jsp/src/main/java/org/apache/sling/scripting/jsp/JspServletWrapperAdapter.java
(original)
+++ incubator/sling/trunk/scripting-jsp/src/main/java/org/apache/sling/scripting/jsp/JspServletWrapperAdapter.java
Sun Sep 23 10:36:33 2007
@@ -21,93 +21,87 @@
 import javax.servlet.ServletConfig;
 import javax.servlet.ServletException;
 import javax.servlet.http.HttpServletRequest;
-import javax.servlet.http.HttpServletResponse;
 
 import org.apache.jasper.Constants;
 import org.apache.jasper.JasperException;
 import org.apache.jasper.Options;
 import org.apache.jasper.compiler.JspRuntimeContext;
 import org.apache.jasper.servlet.JspServletWrapper;
-import org.apache.sling.scripting.HttpServletAdapter;
+import org.apache.sling.component.ComponentException;
+import org.apache.sling.component.ComponentRequest;
+import org.apache.sling.component.ComponentResponse;
+import org.apache.sling.scripting.ComponentRenderer;
 
 /**
  * The <code>JspServletWrapperAdapter</code> TODO
- *
+ * 
  * @author fmeschbe
  * @version $Rev:23741 $, $Date:2006-12-01 16:24:05 +0100 (Fr, 01 Dez 2006) $
  */
-public class JspServletWrapperAdapter extends JspServletWrapper {
-
-    private HttpServletAdapter httpServletAdapter;
+public class JspServletWrapperAdapter extends JspServletWrapper implements
+        ComponentRenderer {
 
     JspServletWrapperAdapter(ServletConfig config, Options options,
-        String jspUri, boolean isErrorPage, JspRuntimeContext rctxt)
+            String jspUri, boolean isErrorPage, JspRuntimeContext rctxt)
             throws JasperException {
         super(config, options, jspUri, isErrorPage, rctxt);
     }
 
-    HttpServletAdapter getServletAdapter() {
-        if (this.httpServletAdapter == null) {
-            this.httpServletAdapter = new JspHttpServletAdapter();
+    public void service(ComponentRequest request, ComponentResponse response)
+            throws IOException, ComponentException {
+        try {
+            service(request, response, preCompile(request));
+        } catch (ComponentException ce) {
+            // just rethrow
+            throw ce;
+        } catch (ServletException se) {
+            // convert to ComponentException
+            throw new ComponentException(se.getMessage(), se);
         }
-
-        return this.httpServletAdapter;
     }
 
-    private class JspHttpServletAdapter extends HttpServletAdapter {
+    /**
+     * <p>
+     * Look for a <em>precompilation request</em> as described in Section
+     * 8.4.2 of the JSP 1.2 Specification. <strong>WARNING</strong> - we cannot
+     * use <code>request.getParameter()</code> for this, because that will
+     * trigger parsing all of the request parameters, and not give a servlet the
+     * opportunity to call <code>request.setCharacterEncoding()</code> first.
+     * </p>
+     * 
+     * @param request The servlet requset we are processing
+     * @exception ServletException if an invalid parameter value for the
+     *                <code>jsp_precompile</code> parameter name is specified
+     */
+    boolean preCompile(HttpServletRequest request) throws ServletException {
+
+        // assume it is ok to access the parameters here, as we are not a
+        // toplevel servlet
+        String jspPrecompile = request.getParameter(Constants.PRECOMPILE);
+        if (jspPrecompile == null) {
+            return false;
+        }
+
+        if (jspPrecompile.length() == 0) {
+            return true; // ?jsp_precompile
+        }
 
-        protected void service(HttpServletRequest request,
-                HttpServletResponse response) throws IOException,
-                ServletException {
-            JspServletWrapperAdapter.this.service(request, response,
-                this.preCompile(request));
+        if (jspPrecompile.equals("true")) {
+            return true; // ?jsp_precompile=true
         }
 
-        /**
-         * <p>
-         * Look for a <em>precompilation request</em> as described in Section
-         * 8.4.2 of the JSP 1.2 Specification. <strong>WARNING</strong> - we
-         * cannot use <code>request.getParameter()</code> for this, because
-         * that will trigger parsing all of the request parameters, and not give
-         * a servlet the opportunity to call
-         * <code>request.setCharacterEncoding()</code> first.
-         * </p>
-         *
-         * @param request The servlet requset we are processing
-         * @exception ServletException if an invalid parameter value for the
-         *                <code>jsp_precompile</code> parameter name is
-         *                specified
-         */
-        boolean preCompile(HttpServletRequest request) throws ServletException {
-
-            // assume it is ok to access the parameters here, as we are not a
-            // toplevel servlet
-            String jspPrecompile = request.getParameter(Constants.PRECOMPILE);
-            if (jspPrecompile == null) {
-                return false;
-            }
-
-            if (jspPrecompile.length() == 0) {
-                return true; // ?jsp_precompile
-            }
-
-            if (jspPrecompile.equals("true")) {
-                return true; // ?jsp_precompile=true
-            }
-
-            if (jspPrecompile.equals("false")) {
-                // Spec says if jsp_precompile=false, the request should not
-                // be delivered to the JSP page; the easiest way to implement
-                // this is to set the flag to true, and precompile the page
-                // anyway.
-                // This still conforms to the spec, since it says the
-                // precompilation request can be ignored.
-                return true; // ?jsp_precompile=false
-            }
-
-            // unexpected value, fail
-            throw new ServletException("Cannot have request parameter "
-                + Constants.PRECOMPILE + " set to " + jspPrecompile);
+        if (jspPrecompile.equals("false")) {
+            // Spec says if jsp_precompile=false, the request should not
+            // be delivered to the JSP page; the easiest way to implement
+            // this is to set the flag to true, and precompile the page
+            // anyway.
+            // This still conforms to the spec, since it says the
+            // precompilation request can be ignored.
+            return true; // ?jsp_precompile=false
         }
+
+        // unexpected value, fail
+        throw new ServletException("Cannot have request parameter "
+            + Constants.PRECOMPILE + " set to " + jspPrecompile);
     }
 }



Mime
View raw message