How can I further optimize my servlets?

Govind Seshadri

You can always wring out some efficiency by making use of a StringBuffer or ByteArray.

For example, instead of sending your HTML to the client using a PrintWriter or some other output stream, you can write it out to a StringBuffer, and send it to the client using just one write invocation. Of course, you'll have to indicate the length of your data stream in the HTTP header too as shown below:

 PrintWriter out = res.getWriter();
 StringBuffer sb = new StringBuffer();
 //concatenate html to StringBuffer
 //set len and write it out