If a servlet which does some significant task gets hit with enough concurrent users, it will eventually throw a java.lang.OutOfMemory exception. Is there a graceful way to handle/avoid this?

Simon Wong

Because the initial memory occupied by the JVM is only 2Mb, you can assign more memory for the JVM such that the OutOfMemory Error won't occur.

There is a non-standard parameter -Xmsn for the java launcher, where n is the multiple of 1024 greater than 2Mb. See http://java.sun.com/j2se/1.3/docs/tooldocs/win32/java.html for more about this option.