You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@cocoon.apache.org by gr...@locus.apache.org on 2000/11/20 19:36:03 UTC

cvs commit: xml-cocoon/src/org/apache/cocoon Engine.java

greenrd     00/11/20 10:36:01

  Modified:    .        changes.xml todo.xml
               src/org/apache/cocoon Engine.java
  Added:       src/org/apache/cocoon/response
                        HttpServletResponseFacade.java
                        RedirectException.java
  Log:
  workaround for Tomcat redirect problems
  
  Revision  Changes    Path
  1.152     +3 -0      xml-cocoon/changes.xml
  
  Index: changes.xml
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/changes.xml,v
  retrieving revision 1.151
  retrieving revision 1.152
  diff -u -r1.151 -r1.152
  --- changes.xml	2000/11/20 18:04:39	1.151
  +++ changes.xml	2000/11/20 18:35:55	1.152
  @@ -4,7 +4,7 @@
   
   <!--
     History of Cocoon changes   
  -  $Id: changes.xml,v 1.151 2000/11/20 18:04:39 greenrd Exp $ 
  +  $Id: changes.xml,v 1.152 2000/11/20 18:35:55 greenrd Exp $ 
   -->
   
   <changes title="History of Changes">
  @@ -18,6 +18,9 @@
     </devs>
   
    <release version="@version@" date="@date@">
  +  <action dev="RDG" type="fix">
  +   Fixed response.sendRedirect problem with Tomcat
  +  </action>
     <action dev="RDG" type="update" due-to="Matt Sergeant"
      due-to-email="matt@sergeant.org">
      Renamed xsp:cacheable to util:cacheable because this is Cocoon-specific
  
  
  
  1.48      +1 -10     xml-cocoon/todo.xml
  
  Index: todo.xml
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/todo.xml,v
  retrieving revision 1.47
  retrieving revision 1.48
  diff -u -r1.47 -r1.48
  --- todo.xml	2000/11/14 18:42:36	1.47
  +++ todo.xml	2000/11/20 18:35:56	1.48
  @@ -3,7 +3,7 @@
   <!DOCTYPE todo SYSTEM "./xdocs/dtd/todo-v10.dtd">
   
   <!--
  -  $Id: todo.xml,v 1.47 2000/11/14 18:42:36 greenrd Exp $
  +  $Id: todo.xml,v 1.48 2000/11/20 18:35:56 greenrd Exp $
   -->
   
   <todo title="Things To Do for Cocoon 1.x">
  @@ -22,9 +22,6 @@
     <action context="code">
      Track down cause of OutOfMemoryError.
     </action>
  -  <action context="docs" assigned-to="RDG">
  -   Contribution / patch management system (will be primitive!)
  -  </action>
     <action context="code">
      Work out how to integrate inline XSP docs (such as inline esql docs)
      into the build docs procedure. This will fix a dead link which leads
  @@ -32,12 +29,6 @@
     </action>
     <action context="docs" assigned-to="RDG">
      Fix dead links in docs.
  -  </action>
  -  <action context="code" assigned-to="RDG">
  -   Workaround redirect problem with Tomcat and IE and Cocoon
  -   (code written; just needs to be merged in.) I marked this high-priority
  -   because the only known workarounds are stop using Tomcat 3.1 or stop using
  -   IE(!) - both of which are unacceptable.
     </action>
    </actions>
   
  
  
  
  1.1                  xml-cocoon/src/org/apache/cocoon/response/HttpServletResponseFacade.java
  
  Index: HttpServletResponseFacade.java
  ===================================================================
  /*-- $Id: HttpServletResponseFacade.java,v 1.1 2000/11/20 18:35:58 greenrd Exp $ --
   
   ============================================================================
                     The Apache Software License, Version 1.1
   ============================================================================
   
   Copyright (C) @year@ The Apache Software Foundation. All rights reserved.
   
   Redistribution and use in source and binary forms, with or without modifica-
   tion, are permitted provided that the following conditions are met:
   
   1. Redistributions of  source code must  retain the above copyright  notice,
      this list of conditions and the following disclaimer.
   
   2. Redistributions in binary form must reproduce the above copyright notice,
      this list of conditions and the following disclaimer in the documentation
      and/or other materials provided with the distribution.
   
   3. The end-user documentation included with the redistribution, if any, must
      include  the following  acknowledgment:  "This product includes  software
      developed  by the  Apache Software Foundation  (http://www.apache.org/)."
      Alternately, this  acknowledgment may  appear in the software itself,  if
      and wherever such third-party acknowledgments normally appear.
   
   4. The names "Cocoon" and  "Apache Software Foundation"  must not be used to
      endorse  or promote  products derived  from this  software without  prior
      written permission. For written permission, please contact
      apache@apache.org.
   
   5. Products  derived from this software may not  be called "Apache", nor may
      "Apache" appear  in their name,  without prior written permission  of the
      Apache Software Foundation.
   
   THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
   INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
   FITNESS  FOR A PARTICULAR  PURPOSE ARE  DISCLAIMED.  IN NO  EVENT SHALL  THE
   APACHE SOFTWARE  FOUNDATION  OR ITS CONTRIBUTORS  BE LIABLE FOR  ANY DIRECT,
   INDIRECT, INCIDENTAL, SPECIAL,  EXEMPLARY, OR CONSEQUENTIAL  DAMAGES (INCLU-
   DING, BUT NOT LIMITED TO, PROCUREMENT  OF SUBSTITUTE GOODS OR SERVICES; LOSS
   OF USE, DATA, OR  PROFITS; OR BUSINESS  INTERRUPTION)  HOWEVER CAUSED AND ON
   ANY  THEORY OF LIABILITY,  WHETHER  IN CONTRACT,  STRICT LIABILITY,  OR TORT
   (INCLUDING  NEGLIGENCE OR  OTHERWISE) ARISING IN  ANY WAY OUT OF THE  USE OF
   THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
   
   This software  consists of voluntary contributions made  by many individuals
   on  behalf of the Apache Software  Foundation and was  originally created by
   Stefano Mazzocchi  <st...@apache.org>. For more  information on the Apache                                      
   Software Foundation, please see <http://www.apache.org/>.
   
   */
   
  package org.apache.cocoon.response;
  
  import java.io.IOException;
  import java.io.PrintWriter;
  import java.util.Locale;
  import javax.servlet.*;
  import javax.servlet.http.*;
  
  /**
   * Hack to handle redirects correctly with Tomcat 3.1.
   *
   * @author <a href="mailto:greenrd@hotmail.com">Robin Green</a>
   * @version $Revision: 1.1 $ $Date: 2000/11/20 18:35:58 $
   */
  
  public class HttpServletResponseFacade implements HttpServletResponse {
  
    protected final HttpServletResponse r;
  
    public HttpServletResponseFacade (HttpServletResponse response) {
      r = response;
    }
  
    public void setContentLength(int len) {
      r.setContentLength (len);
    }
  
    public void setContentType(String type) {
      r.setContentType (type);
    }
  
    public ServletOutputStream getOutputStream() throws IOException {
      return r.getOutputStream ();
    }
  
    public PrintWriter getWriter () throws IOException {
      return r.getWriter ();
    }
  
    public String getCharacterEncoding() {
      return r.getCharacterEncoding ();
    }
  
    public void addCookie(Cookie cookie) {
      r.addCookie (cookie);
    }
  
    public boolean containsHeader(String name) {
      return r.containsHeader (name);
    }
  
    public void setStatus(int sc) {
      r.setStatus (sc);
    }
  
    public void setHeader(String name, String value) {
      r.setHeader (name, value);
    }
  
    public void setIntHeader(String name, int value) {
      r.setIntHeader (name, value);
    }
  
    public void setDateHeader(String name, long date) {
      r.setDateHeader (name, date);
    }
  
    public void sendError(int sc, String msg) throws IOException {
      r.sendError (sc, msg);
    }
  
    public void sendError(int sc) throws IOException {
      r.sendError (sc);
    }
  
    public void sendRedirect(String location) throws IOException, RedirectException {
      r.sendRedirect (location);
      throw new RedirectException ();
    }
  
    public String encodeURL (String url) {
      return r.encodeURL (url);
    }
  
    public String encodeRedirectURL (String url) {
      return r.encodeRedirectURL (url);
    }
  
    public void setBufferSize(int size) {
      r.setBufferSize (size);
    }
  
    public int getBufferSize() {
      return r.getBufferSize ();
    }
  
    public void flushBuffer() throws IOException {
      r.flushBuffer ();
    }
  
    public boolean isCommitted() {
      return r.isCommitted ();
    }
  
    public void reset() {
      r.reset ();
    }
  
    public void setLocale(Locale locale) {
      r.setLocale (locale);
    }
  
    public Locale getLocale() {
      return r.getLocale ();
    }
  
    public void addDateHeader(String name, long date) {
      r.addDateHeader (name, date);
    }
  
    public void addHeader(String name, String value) {
      r.addHeader (name, value);
    }
  
    public void addIntHeader(String name, int value) {
      r.addIntHeader (name, value);
    }
  
    /** @deprecated */
    public void setStatus(int sc, String sm) {
      r.setStatus (sc, sm);
    }
  
    /** @deprecated */
    public String encodeUrl (String url) {
      return r.encodeUrl (url);
    }
  
    /** @deprecated */
    public String encodeRedirectUrl (String url) {
      return r.encodeRedirectUrl (url);
    }
  }
  
  
  
  1.1                  xml-cocoon/src/org/apache/cocoon/response/RedirectException.java
  
  Index: RedirectException.java
  ===================================================================
  /*-- $Id: RedirectException.java,v 1.1 2000/11/20 18:35:59 greenrd Exp $ --
   
   ============================================================================
                     The Apache Software License, Version 1.1
   ============================================================================
   
   Copyright (C) @year@ The Apache Software Foundation. All rights reserved.
   
   Redistribution and use in source and binary forms, with or without modifica-
   tion, are permitted provided that the following conditions are met:
   
   1. Redistributions of  source code must  retain the above copyright  notice,
      this list of conditions and the following disclaimer.
   
   2. Redistributions in binary form must reproduce the above copyright notice,
      this list of conditions and the following disclaimer in the documentation
      and/or other materials provided with the distribution.
   
   3. The end-user documentation included with the redistribution, if any, must
      include  the following  acknowledgment:  "This product includes  software
      developed  by the  Apache Software Foundation  (http://www.apache.org/)."
      Alternately, this  acknowledgment may  appear in the software itself,  if
      and wherever such third-party acknowledgments normally appear.
   
   4. The names "Cocoon" and  "Apache Software Foundation"  must not be used to
      endorse  or promote  products derived  from this  software without  prior
      written permission. For written permission, please contact
      apache@apache.org.
   
   5. Products  derived from this software may not  be called "Apache", nor may
      "Apache" appear  in their name,  without prior written permission  of the
      Apache Software Foundation.
   
   THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED WARRANTIES,
   INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
   FITNESS  FOR A PARTICULAR  PURPOSE ARE  DISCLAIMED.  IN NO  EVENT SHALL  THE
   APACHE SOFTWARE  FOUNDATION  OR ITS CONTRIBUTORS  BE LIABLE FOR  ANY DIRECT,
   INDIRECT, INCIDENTAL, SPECIAL,  EXEMPLARY, OR CONSEQUENTIAL  DAMAGES (INCLU-
   DING, BUT NOT LIMITED TO, PROCUREMENT  OF SUBSTITUTE GOODS OR SERVICES; LOSS
   OF USE, DATA, OR  PROFITS; OR BUSINESS  INTERRUPTION)  HOWEVER CAUSED AND ON
   ANY  THEORY OF LIABILITY,  WHETHER  IN CONTRACT,  STRICT LIABILITY,  OR TORT
   (INCLUDING  NEGLIGENCE OR  OTHERWISE) ARISING IN  ANY WAY OUT OF THE  USE OF
   THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
   
   This software  consists of voluntary contributions made  by many individuals
   on  behalf of the Apache Software  Foundation and was  originally created by
   Stefano Mazzocchi  <st...@apache.org>. For more  information on the Apache                                      
   Software Foundation, please see <http://www.apache.org/>.
   
   */
   
  package org.apache.cocoon.response;
  
  /**
   * Hack to handle redirects correctly with Tomcat 3.1.
   *
   * @author <a href="mailto:greenrd@hotmail.com">Robin Green</a>
   * @version $Revision: 1.1 $ $Date: 2000/11/20 18:35:59 $
   */
  
  public class RedirectException extends RuntimeException {
    /**
     * Package-private constructor - this should only be called from
     * HttpServletResponseFacade.
     */
    RedirectException () {}  
  }
  
  
  
  1.39      +7 -0      xml-cocoon/src/org/apache/cocoon/Engine.java
  
  Index: Engine.java
  ===================================================================
  RCS file: /home/cvs/xml-cocoon/src/org/apache/cocoon/Engine.java,v
  retrieving revision 1.38
  retrieving revision 1.39
  diff -u -r1.38 -r1.39
  --- Engine.java	2000/11/20 01:43:53	1.38
  +++ Engine.java	2000/11/20 18:36:00	1.39
  @@ -1,4 +1,4 @@
  -/*-- $Id: Engine.java,v 1.38 2000/11/20 01:43:53 greenrd Exp $ --
  +/*-- $Id: Engine.java,v 1.39 2000/11/20 18:36:00 greenrd Exp $ --
   
    ============================================================================
                      The Apache Software License, Version 1.1
  @@ -67,6 +67,8 @@
   import org.apache.cocoon.processor.*;
   import org.apache.cocoon.framework.*;
   import org.apache.cocoon.interpreter.*;
  +import org.apache.cocoon.response.HttpServletResponseFacade;
  +import org.apache.cocoon.response.RedirectException;
   
   /**
    * The Cocoon publishing engine.
  @@ -75,7 +77,7 @@
    *
    * @author <a href="mailto:stefano@apache.org">Stefano Mazzocchi</a>
    * @author <a href="mailto:greenrd@hotmail.com">Robin Green</a>
  - * @version $Revision: 1.38 $ $Date: 2000/11/20 01:43:53 $
  + * @version $Revision: 1.39 $ $Date: 2000/11/20 18:36:00 $
    */
   
   public class Engine implements Defaults {
  @@ -292,6 +294,8 @@
               System.setErr(stream);
           }
   
  +        response = new HttpServletResponseFacade (response);
  +
           Page page = null;
   
           boolean lock = false;
  @@ -461,6 +465,9 @@
               if (LOG) logger.log(this, "response sent to client", Logger.WARNING);
               if (PROFILE) profiler.finishEvent (requestMarker, WHOLE_REQUEST);
   
  +        } catch (RedirectException ex) {
  +            // Do nothing - this is used to immediately stop Cocoon processing
  +            // to fix a redirect bug on some servlet engines, e.g. Tomcat.
           } finally {
               // if there is a lock make sure it is released,
               // otherwise this page could never be served