glenn       2002/09/26 06:35:31

  Modified:    catalina/src/share/org/apache/catalina/core
                        StandardWrapper.java
  Log:
  Add test for swallowOutput for capturing System.out
  
  Revision  Changes    Path
  1.41      +23 -11    
jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/core/StandardWrapper.java
  
  Index: StandardWrapper.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-tomcat-4.0/catalina/src/share/org/apache/catalina/core/StandardWrapper.java,v
  retrieving revision 1.40
  retrieving revision 1.41
  diff -u -r1.40 -r1.41
  --- StandardWrapper.java      29 Aug 2002 10:37:55 -0000      1.40
  +++ StandardWrapper.java      26 Sep 2002 13:35:31 -0000      1.41
  @@ -249,6 +249,11 @@
       private Stack instancePool = null;
   
   
  +    /**
  +     * Should we swallow System.out
  +     */
  +    private boolean swallowOutput = false;
  +
       // ------------------------------------------------------------- Properties
   
   
  @@ -460,6 +465,9 @@
               !(container instanceof Context))
               throw new IllegalArgumentException
                   (sm.getString("standardWrapper.notContext"));
  +        if (container instanceof StandardContext) {
  +            swallowOutput = ((StandardContext)container).getSwallowOutput();
  +        }
           super.setParent(container);
   
       }
  @@ -827,7 +835,9 @@
               return instance;
   
           PrintStream out = System.out;
  -        SystemLogHandler.startCapture();
  +        if (swallowOutput) {
  +            SystemLogHandler.startCapture();
  +        }
           Servlet servlet = null;
           try {
               // If this "servlet" is really a JSP file, get the right class.
  @@ -961,12 +971,14 @@
               }
               fireContainerEvent("load", this);
           } finally {
  -            String log = SystemLogHandler.stopCapture();
  -            if (log != null && log.length() > 0) {
  -                if (getServletContext() != null) {
  -                    getServletContext().log(log);
  -                } else {
  -                    out.println(log);
  +            if (swallowOutput) {
  +                String log = SystemLogHandler.stopCapture();
  +                if (log != null && log.length() > 0) {
  +                    if (getServletContext() != null) {
  +                        getServletContext().log(log);
  +                    } else {
  +                        out.println(log);
  +                    }
                   }
               }
           }
  
  
  

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to