Return-Path: Delivered-To: apmail-incubator-sling-commits-archive@locus.apache.org Received: (qmail 53522 invoked from network); 10 Oct 2008 13:33:44 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 10 Oct 2008 13:33:44 -0000 Received: (qmail 37096 invoked by uid 500); 10 Oct 2008 13:33:43 -0000 Delivered-To: apmail-incubator-sling-commits-archive@incubator.apache.org Received: (qmail 37061 invoked by uid 500); 10 Oct 2008 13:33:43 -0000 Mailing-List: contact sling-commits-help@incubator.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: sling-dev@incubator.apache.org Delivered-To: mailing list sling-commits@incubator.apache.org Received: (qmail 37050 invoked by uid 99); 10 Oct 2008 13:33:43 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 10 Oct 2008 06:33:43 -0700 X-ASF-Spam-Status: No, hits=-1999.9 required=10.0 tests=ALL_TRUSTED,DNS_FROM_SECURITYSAGE X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 10 Oct 2008 13:32:47 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id 9835C23888F4; Fri, 10 Oct 2008 06:33:23 -0700 (PDT) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit 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 -0000 To: sling-commits@incubator.apache.org From: fmeschbe@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20081010133323.9835C23888F4@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org 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() {