This chapter focuses on using JavaEE—specifically, JavaEE 6 and 7. It covers JSPs, servlets, and EJB 3.0 Session Beans—though not EJB 3.0 Entity Beans (Java Persistence API entities), since the are not specifically a JavaEE technology (they are discussed in depth in Chapter 11).
The heart of a JavaEE application server is the performance of its web container, which handles HTTP requests via basic servlets and JSP pages.
Here are the basic ways to improve performance of the web container. The details of how these changes are made vary depending on the Java EE implementation, but the concepts apply to any server.
Produce less output
Producing less output will speed up the time it takes your web page to get to the browser.
Produce less whitespace
In servlet code, don’t put whitespace in calls to the
that whitespace takes time to transmit over the network (and,
for that matter, to process in the code, but the network time is more
important). This means you should call the
in preference to
println() method, but it primarily means not writing tabs or spaces to reflect the structure of the HTML. It is true that someone who views the source of the web page won’t see its structure, though they can always use an XML or HTML editor if they’re really interested in that. That applies to an in-house QA or performance group too: certainly it makes my job easier when debugging a web page ...