Howdy -
Long email, so bear with me pls :-) This is probably old hat to the
experts, but it was a real eye-opener for me.
Most of my servlets are structured like this:
==========================
public void doGet(HttpServletRequest req, HttpServletResponse res) throws
ServletException, IOException {
String html = processRequestAndGetResults(req)); // or something
like that
res.setContentType("text/html");
ServletOutputStream out = res.getOutputStream();
out.println(html); // <--------------hmmmm.....
out.close();
}
==========================
One simple change:
==========================
out.write(html.getBytes());
==========================
makes this code MUCH faster. Specifically, I observed the
following performance for sample large & small pages:
write(getBytes() println()
========= =========
266K page 80 ms 871 ms
7K page 20 ms 70 ms
I don't know... maybe everyone is doing this already... but I
wasn't, and now my servlets are noticeably faster - and, as far as I can
tell, the performance gain is "free". So, is there something I'm missing
here? Does using out.write(html.getBytes()); do something bad? If not...
why do many servlet books and tutorials use the OutputStream println()
method?
Thanks,
Tom
___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".
Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html