incubator-sling-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fmesc...@apache.org
Subject svn commit: r703451 - /incubator/sling/trunk/engine/src/main/java/org/apache/sling/engine/impl/request/SlingRequestDispatcher.java
Date Fri, 10 Oct 2008 13:33:23 GMT
Author: fmeschbe
Date: Fri Oct 10 06:33:23 2008
New Revision: 703451

URL: http://svn.apache.org/viewvc?rev=703451&view=rev
Log:
SLING-692 Implement forward in terms of a simple include

Modified:
    incubator/sling/trunk/engine/src/main/java/org/apache/sling/engine/impl/request/SlingRequestDispatcher.java

Modified: incubator/sling/trunk/engine/src/main/java/org/apache/sling/engine/impl/request/SlingRequestDispatcher.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/engine/src/main/java/org/apache/sling/engine/impl/request/SlingRequestDispatcher.java?rev=703451&r1=703450&r2=703451&view=diff
==============================================================================
--- incubator/sling/trunk/engine/src/main/java/org/apache/sling/engine/impl/request/SlingRequestDispatcher.java
(original)
+++ incubator/sling/trunk/engine/src/main/java/org/apache/sling/engine/impl/request/SlingRequestDispatcher.java
Fri Oct 10 06:33:23 2008
@@ -119,15 +119,32 @@
             }
         }
 
-        cRequest.getRequestProgressTracker().log("Including resource {0} ({1})", resource,
info);
+        cRequest.getRequestProgressTracker().log(
+            "Including resource {0} ({1})", resource, info);
         rd.getSlingMainServlet().includeContent(request, response, resource,
             info);
     }
 
     public void forward(ServletRequest request, ServletResponse response)
             throws ServletException, IOException {
-        // TODO Auto-generated method stub
-        // TODO, use servlet container dispatcher !!
+
+        // fail forwarding if the response has already been committed
+        if (response.isCommitted()) {
+            throw new IllegalStateException("Response already committed");
+        }
+
+        // reset the response, will throw an IllegalStateException
+        // if already committed, which will not be the case because
+        // we already tested for this condition
+        response.reset();
+
+        // now just include as normal
+        include(request, response);
+
+        // finally, we would have to ensure the response is committed
+        // and closed. Let's just flush the buffer and thus commit the
+        // response for now
+        response.flushBuffer();
     }
 
     private String getAbsolutePath(SlingHttpServletRequest request, String path) {
@@ -167,9 +184,9 @@
         }
 
         /**
-         * Overwrite this here because the wrapped resource will return a
-         * super type based on the resource type of the wrapped resource
-         * instead of the resource type overwritten here
+         * Overwrite this here because the wrapped resource will return a super
+         * type based on the resource type of the wrapped resource instead of
+         * the resource type overwritten here
          */
         @Override
         public String getResourceSuperType() {



Mime
View raw message