There are some Java methods that are not suitable for use in a Web server application, including:

java.net.URLEncoder.encode()

This method is quite inefficient. It is slow and uses a lot of memory. Instead, use the method atg.servlet.ServletUtil.escapeURLString() to perform the same function 10 times faster and with much less memory allocated.

java.util.Date.toString()

In at least some JDK versions, this is a synchronized method that takes a fair amount of CPU time. Instead, use a method like the following to format a Date more efficiently:

StringBuffer sb = new StringBuffer(NumberFormat.
fixedWidth( (date.getMonth()+1), 2));
sb.append("/");
sb.append( NumberFormat.fixedWidth(date.getDate(), 2) );
sb.append("/");
/* need to cut the 100's of Year ex. if it is 102 for 2002 */
sb.append( NumberFormat.fixedWidth((date.getYear()%100), 2) );
return ( sb.toString() );

For additional material on programming efficiently and troubleshooting performance problems, refer to the performance-related chapters in the Installation and Configuration Guide for your application server.

 
loading table of contents...