Jtest logo




Contents  Previous  Next  Index

SERVLET.SOP


Minimize use of System.out.println or System.err

Description

This rule flags code that uses System.out.println or System.err.

Because System.out.prinln statements and similar constructs synchronize processing for the duration of disk I/O, they can significantly slow throughput.

Example

 package SERVLET;
 
 import javax.servlet.*;
 import javax.servlet.http.*;
 
 public class SOP extends HttpServlet {
     public void service () {
         System.out.println ("starting service");
     }
 }

Repair

 public class SOP extends HttpServlet {
     private final static boolean DEBUG_ON = false;
     public void service () {
         // activate tracing only when absolutely needed.
         if (DEBUG_ON) {
             System.out.println ("starting service");
         }
     }
 }

Reference

IBM WebSphere Application Server Standard and Advanced Editions, Harvey W. Gunther.

http://www-4.ibm.com/software/webservers/appserv/ws_bestpractices.pdf


Contents  Previous  Next  Index

ParaSoft logo
(888) 305-0041 info@parasoft.com Copyright © 1996-2001 ParaSoft