tomcat-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Apache Wiki <wikidi...@apache.org>
Subject [Tomcat Wiki] Update of "HowTo" by KonstantinKolinko
Date Sat, 02 Feb 2013 22:50:28 GMT
Dear Wiki user,

You have subscribed to a wiki page or wiki category on "Tomcat Wiki" for change notification.

The "HowTo" page has been changed by KonstantinKolinko:
http://wiki.apache.org/tomcat/HowTo?action=diff&rev1=128&rev2=129

Comment:
Add "try" and "finally"

                  PrintStream oStdOutBackup = System.out;
                  PrintStream oStdErrBackup = System.err;
  
+                 try {
+ 
-                 // Redired STDOUT and STDERR to the ServletOuputStream
+                   // Redired STDOUT and STDERR to the ServletOutputStream
-                 System.setOut(new PrintStream(out));
+                   System.setOut(new PrintStream(out));
-                 System.setErr(new PrintStream(out));
+                   System.setErr(new PrintStream(out));
  
- 
-                 try
+                   try {
-                 {
                          // ... call compiler here that produces
                          // tons of STDOUT/STDERR messages ...
+                   } catch(Exception e) {
+                         out.println(e);
+                   }
+ 
+                 } finally {
+ 
+                   // Restore original STDOUT and STDERR
+                   System.setOut(oStdOutBackup);
+                   System.setErr(oStdErrBackup);
+ 
                  }
-                 catch(Exception e)
-                 {
-                         out.println(e);
-                 }
- 
-                 // Restore original STDOUT and STDERR
-                 System.setOut(oStdOutBackup);
-                 System.setErr(oStdErrBackup);
  
                  out.println("<hr />");
                  out.println("</body>");

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Mime
View raw message