Java Reference
In-Depth Information
Chapter 10. Java Enterprise Edition
This chapter focuses on using Java EE (specifically, Java EE 6 and 7). It covers JSPs, ser-
vlets, and EJB 3.0 Session Beans—though not EJB 3.0 Entity Beans (Java Persistence API
entities), since they are not specifically a Java EE technology (they are discussed in depth in
Chapter 11 ) .
Basic Web Container Performance
The heart of a Java EE 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 ap-
ply 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 PrintWriter ; that whitespace takes
time to transmit over the network (and, for that matter, to process in the code, but the net-
work time is more important). This means you should call the print() method in prefer-
ence to the println() method, but it primarily means not writing tabs or spaces to re-
flect 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 if the source reflects
the structure of the page. But in the end, I'll put up with loading the source into a format-
ting editor in order to improve the application's response time. Most application servers
can trim the whitespace out of JSPs automatically; for example, in Tomcat (and open
source Java EE servers based on Tomcat), there is a trimSpaces directive that will trim
Search WWH ::

Custom Search