JavaServer Pages, together with the Java Servlet, provide the dynamic web content presentation layer for the Java 2 Enterprise Edition. JSPs and Servlets integrate tightly to enable scalable and portable applications, and are widely supported. This book targets the next generation of these technologies, JSP 1.2 and Servlets 2.3, which are nearing completion under the Java Community Process and provide major enhancements to Java's web programming model.
By submitting your email address, you agree to receive emails regarding relevant topic offers from TechTarget and its partners. You can withdraw your consent at any time. Contact TechTarget at 275 Grove Street, Newton, MA.
This book looks in depth at these core components of the forthcoming J2EE 1.3 platform, preparing you for building the next generation of web solutions. You'll learn about the enhancements to the JSP tag library model; the new filtering and application event facilities; how to architect web applications to ensure a clean separation of presentation and logic; and the increasingly popular Jakarta Struts framework. The book also addresses using JSP with XML and XSLT; database access with JDBC; and how JSP and Servlets fit into the overall J2EE platform alongside Enterprise JavaBeans, JavaMail, and other J2EE technologies.
Chapter 20 - Performance
Getting your web applications to do what you want is one thing; getting them to do it fast and efficiently is often another. This chapter will explore some general strategies and specific techniques for optimizing Servlets and JavaServer Pages.
Critical to optimizing a web application for high performance is establishing what 'high performance' actually means. Two common metrics are used to establish an objective measurement of a web application's performance: speed and scalability.
'Speed' in the context of web applications has at least two meanings. For the average user browsing the web at home on a dial-up connection, the speed of a website is closely related to the number of graphics required to render the web page in a usable manner. A poorly-designed highly graphical dynamic website would be measured as 'slow' in this sense, although the web application serving the web pages might be performing extremely 'fast'. This sense of speed is controlled by the presentation technology, which is typically HTML. This topic is outside the scope of this book, but it's worth reviewing from other sources to ensure that your presentation layer doesn't spoil the backend performance of your web application.
Another meaning of a web application's speed is how fast it is able to respond to a request. Home-based users with broadband technology or work-based intranet users are likely to associate a website's speed with this measurement. Nearly all of the optimization techniques in this chapter relate to this measurement of speed, as it is directly related to the efficiency of the Java code and other server-side factors.
Along with speed, scalability is an important measure of a web application's performance. While speed focuses on the amount of time that passes between the client's request and the server's response, scalability measures how many simultaneous requests a web application can process before its speed deteriorates to unacceptable levels.
No web application can handle an unlimited number of requests; the trick in optimization is to anticipate the likely user demand and ensure that the web site can gracefully scale up to the demand while maintaining acceptable levels of speed. Stress testing is a common process for determining the scalability of a web application. Stress testing simulates a high volume of users, measuring the deterioration of the web application's speed until it is no longer within acceptable tolerances, or simply melts down.
Stress testing identifies the general areas of the web application that require optimization. With this information, profiling techniques can be used to determine what specific portions of the web application's code are the best candidates for optimization. Profiling tools and techniques develop a performance 'profile' of a Java class, paying special attention to the speed of each specific method.
In this chapter, we'll examine the following means for improving the performance of our web applications:
- Various methods available to developers for stress testing and profiling their web applications (discovering the limitations and inefficiencies of the web application)
- Next, we'll discuss some specific techniques for optimizing web applications (resolving the discovered inefficiencies)
- We'll also discuss alternative Java Virtual Machines (JVMs) as an effective optimization technique