You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by cr...@locus.apache.org on 2000/09/05 03:52:35 UTC

cvs commit: jakarta-struts/src/share/org/apache/struts/taglib/bean IncludeTag.java ResourceTag.java

craigmcc    00/09/04 18:52:35

  Modified:    src/share/org/apache/struts/taglib/bean IncludeTag.java
                        ResourceTag.java
  Log:
  Add releaseCustomAttributes() method -- for JSP 1.2 compatility -- to
  IncludeTag.  Tune the buffering used when processing input streams in
  IncludeTag and ResourceTag.
  
  Revision  Changes    Path
  1.2       +25 -6     jakarta-struts/src/share/org/apache/struts/taglib/bean/IncludeTag.java
  
  Index: IncludeTag.java
  ===================================================================
  RCS file: /home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/bean/IncludeTag.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- IncludeTag.java	2000/09/05 01:33:21	1.1
  +++ IncludeTag.java	2000/09/05 01:52:34	1.2
  @@ -1,5 +1,5 @@
   /*
  - * $Id: IncludeTag.java,v 1.1 2000/09/05 01:33:21 craigmcc Exp $
  + * $Id: IncludeTag.java,v 1.2 2000/09/05 01:52:34 craigmcc Exp $
    * ====================================================================
    *
    * The Apache Software License, Version 1.1
  @@ -80,7 +80,7 @@
    * wrapped response passed to RequestDispatcher.include().
    *
    * @author Craig R. McClanahan
  - * @version $Revision: 1.1 $ $Date: 2000/09/05 01:33:21 $
  + * @version $Revision: 1.2 $ $Date: 2000/09/05 01:52:34 $
    */
   
   public class IncludeTag extends TagSupport {
  @@ -90,6 +90,12 @@
   
   
       /**
  +     * Buffer size to use when reading the input stream.
  +     */
  +    private static final int BUFFER_SIZE = 256;
  +
  +
  +    /**
        * The name of the scripting variable that will be exposed as a page
        * scope attribute.
        */
  @@ -175,11 +181,13 @@
   	    BufferedInputStream is =
   		new BufferedInputStream(conn.getInputStream());
   	    InputStreamReader in = new InputStreamReader(is); // FIXME - encoding
  +            char buffer[] = new char[BUFFER_SIZE];
  +            int n = 0;
   	    while (true) {
  -		int ch = in.read();
  -		if (ch < 0)
  -		    break;
  -		sb.append(ch);
  +                n = in.read(buffer);
  +                if (n < 1)
  +                    break;
  +                sb.append(buffer, 0, n);
   	    }
               in.close();
   	} catch (Exception e) {
  @@ -192,6 +200,17 @@
   
   	// Skip any body of this tag
   	return (SKIP_BODY);
  +
  +    }
  +
  +
  +    /**
  +     * Reset custom attributes to their default values.
  +     */
  +    public void releaseCustomAttributes() {
  +
  +        id = null;
  +        name = null;
   
       }
   
  
  
  
  1.2       +10 -4     jakarta-struts/src/share/org/apache/struts/taglib/bean/ResourceTag.java
  
  Index: ResourceTag.java
  ===================================================================
  RCS file: /home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/bean/ResourceTag.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- ResourceTag.java	2000/08/30 02:15:06	1.1
  +++ ResourceTag.java	2000/09/05 01:52:34	1.2
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/bean/ResourceTag.java,v 1.1 2000/08/30 02:15:06 craigmcc Exp $
  - * $Revision: 1.1 $
  - * $Date: 2000/08/30 02:15:06 $
  + * $Header: /home/cvs/jakarta-struts/src/share/org/apache/struts/taglib/bean/ResourceTag.java,v 1.2 2000/09/05 01:52:34 craigmcc Exp $
  + * $Revision: 1.2 $
  + * $Date: 2000/09/05 01:52:34 $
    *
    * ====================================================================
    *
  @@ -80,7 +80,7 @@
    * web application resource.
    *
    * @author Craig R. McClanahan
  - * @version $Revision: 1.1 $ $Date: 2000/08/30 02:15:06 $
  + * @version $Revision: 1.2 $ $Date: 2000/09/05 01:52:34 $
    */
   
   public final class ResourceTag extends TagSupport {
  @@ -90,6 +90,12 @@
   
   
       /**
  +     * Buffer size to use when reading the input stream.
  +     */
  +    private static final int BUFFER_SIZE = 256;
  +
  +
  +    /**
        * The name of the scripting variable that will be exposed as a page
        * scope attribute.
        */
  @@ -168,7 +174,7 @@
   	    StringBuffer sb = new StringBuffer();
   	    InputStreamReader reader =
   	      new InputStreamReader(stream);
  -	    char buffer[] = new char[256];
  +	    char buffer[] = new char[BUFFER_SIZE];
   	    int n = 0;
   	    while (true) {
   	        n = reader.read(buffer);