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 2008/01/23 15:33:16 UTC

svn commit: r614547 - /incubator/sling/trunk/sling/servlet-resolver/src/main/java/org/apache/sling/servlet/resolver/helper/SlingScriptServlet.java

Author: fmeschbe
Date: Wed Jan 23 06:33:13 2008
New Revision: 614547

URL: http://svn.apache.org/viewvc?rev=614547&view=rev
Log:
SLING-186 Fix exception handling

Modified:
    incubator/sling/trunk/sling/servlet-resolver/src/main/java/org/apache/sling/servlet/resolver/helper/SlingScriptServlet.java

Modified: incubator/sling/trunk/sling/servlet-resolver/src/main/java/org/apache/sling/servlet/resolver/helper/SlingScriptServlet.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/sling/servlet-resolver/src/main/java/org/apache/sling/servlet/resolver/helper/SlingScriptServlet.java?rev=614547&r1=614546&r2=614547&view=diff
==============================================================================
--- incubator/sling/trunk/sling/servlet-resolver/src/main/java/org/apache/sling/servlet/resolver/helper/SlingScriptServlet.java (original)
+++ incubator/sling/trunk/sling/servlet-resolver/src/main/java/org/apache/sling/servlet/resolver/helper/SlingScriptServlet.java Wed Jan 23 06:33:13 2008
@@ -34,6 +34,7 @@
 
 import org.apache.sling.api.SlingException;
 import org.apache.sling.api.SlingHttpServletRequest;
+import org.apache.sling.api.scripting.ScriptEvaluationException;
 import org.apache.sling.api.scripting.SlingBindings;
 import org.apache.sling.api.scripting.SlingScript;
 
@@ -56,36 +57,28 @@
         this.script = script;
     }
 
-    public void service(ServletRequest req, ServletResponse servletResponse)
-            throws ServletException, IOException {
+    /**
+     * @throws ScriptEvaluationException
+     */
+    public void service(ServletRequest req, ServletResponse servletResponse) {
 
         SlingHttpServletRequest request = (SlingHttpServletRequest) req;
         final HttpServletResponse res = (HttpServletResponse)servletResponse;
 
-        try {
-            // prepare the properties for the script
-            SlingBindings props = new SlingBindings();
-            props.put(REQUEST, req);
-            props.put(RESPONSE, res);
-            props.put(FLUSH, TRUE);
-
-            res.setCharacterEncoding("UTF-8");
-            final String contentType = request.getResponseContentType();
-            if(contentType != null) {
-                res.setContentType(contentType);
-            }
-
-            // evaluate the script now using the ScriptEngine
-            script.eval(props);
-
-        } catch (IOException ioe) {
-            throw ioe;
-        } catch (ServletException se) {
-            throw se;
-        } catch (Exception e) {
-            throw new SlingException("Cannot get DefaultSlingScript: "
-                + e.getMessage(), e);
+        // prepare the properties for the script
+        SlingBindings props = new SlingBindings();
+        props.put(REQUEST, req);
+        props.put(RESPONSE, res);
+        props.put(FLUSH, TRUE);
+
+        res.setCharacterEncoding("UTF-8");
+        final String contentType = request.getResponseContentType();
+        if(contentType != null) {
+            res.setContentType(contentType);
         }
+
+        // evaluate the script now using the ScriptEngine
+        script.eval(props);
     }
 
     public ServletConfig getServletConfig() {