New to Java? We'll help you get started with our revised beginner's tutorial, or our free online textbook.

Get the latest Java books
h t t p : / /w w w . j a v a c o f f e e b r e a k . c o m /

Java Coffee Break


Learning Java

Author Profiles
Talk Java!

Using Java

Discuss Java

Looking for Java resources? Check out the Java Coffee Break directory!

Java Profiles

Dan Malks

Dan Malks is an Enterprise Java Architect with Sun Microsystems, working in the Sun Java Center in McLean, VA. He received a Master of Science degree in Computer Science from Johns Hopkins University in 1996 after having earned a Bachelor of Science in Computer Science from The College of William and Mary in 1987.  He has published articles about Java in leading industry periodicals, in addition to being a contributing author to Professional JSP, Wrox 2000. Most recently, he presented "Prototyping with Patterns for the J2EE platform" at the JavaOne 2000 conference. Currently he has been focusing on Distributed, Service-based architectural designs, patterns and implementations.

Read a review of Professional JSP
Read a sample chapter from his book

Q: What do you see has been the biggest change affecting the Java community in the last year?

A: One of the biggest changes is that twelve months ago, some businesses still needed to be convinced that they should be using Java. Today, there is no longer any need to sell the technology, but rather the issue has become simply how and where to best leverage Java to achieve one's goals.

Another important change that also factors into this widespread adoption of the technology is the availability of scalable application servers that support the Java 2 Platform Enterprise Edition (J2EE). Businesses now have their choice of numerous mature commercial products on which to base their Enterprise applications.

Q: How does Java Server Pages stack up to competing technologies like Microsoft's Active Server Pages (ASP)? Can JSP match the performance and scalability of ASP, or should developers be looking at other issues such as portability and ease-of-use?

A: The most important thing to consider when comparing these two technologies is that Java Server Pages (JSP) are designed to be platform and server independent, while Active Server Pages (ASP) are built on technologies that run natively only on the Microsoft platform. So, if you need to develop and/or deploy your solution on multiple platforms and/or servers, then JSP will provide a more flexible and powerful solution. 

Additionally, JSP pages are compiled and cached in memory, providing extremely fast response time, while ASP pages are normally reinterpreted for each request. In terms of scalability, one need simply look at the growing number of cross-platform, scalable application servers on the market that support the Java 2 Platform Enterprise Edition (J2EE) of which JSP is an integral part. Not only do these containers provide high-performance, scalable, and secure environments that will run on multiple operating systems and hardware platforms, but the fact that they are fully J2EE compliant means the developer has the ability to integrate and leverage the large number of industry-standard Java libraries and APIs, such as:

  • Java Naming and Directory Interface (JNDI)

  • Enterprise JavaBeans (EJB)

  • JDBC Data Access (JDBC)

  • Java Message Service (JMS)

  • Java Mail

  • RMI over IIOP

So, it is hard to argue with the power and flexibility one has when leveraging JSP in combination with the J2EE for developing, deploying, and managing scalable and flexible, service-based architectures.

Q: How do you see JSP in relation to Java servlets? There seems to be a fair bit of overlap between the two. Are there some situations where JSP is preferable to servlets, and vice versa?

A: JSPs are built on Servlet semantics, so the evolution of each of these APIs is important to the JSP community. Version 1.0 of the JSP specification is based on the Servlet API version 2.1. Version 1.1 of the JSP specification is based on the Servlet API version 2.2. 

A JSP page in source form looks more or less like an HTML page, while servlet source is composed entirely of Java code. When servlets alone are used, developers often embed HTML markup directly within their servlet's Java code. Conversely, when developers first encounter JSP, they often embed lots of Java code within their JSPs' HTML. Neither situation is ideal, since each involves overly intermingling business logic with presentation.

One way to think about this issue is to consider the multiple roles that exist on a project. There are individuals who fulfill a software development role and individuals who fulfill a web-production role. Software developers are comfortable working with Java artifacts, such as servlets, while the web-production team is often better suited to deal with the design and layout issues of an HTML presentation page. The aforementioned scenarios, where we have lots of Java mixed with HTML, means that we cannot cleanly separate the work that these individuals have to perform. We have introduced dependencies that can lead to time delays as well as a more buggy environment. As we reduce these dependencies, we create a cleaner role separation and a more efficient and productive work environment.

So, how do we improve this situation? We try and separate our Java code (business logic) from our HTML (presentation markup) as much as possible. But how do we decide what to put where?

In a nutshell:

1) Move HTML out of servlets and into JSPs
2) Move Java code out of JSPs

So, now the question arises:
Where do we move our Java code and what criteria do we use to make these changes? 

1) If the Java code in a JSP is logic that is common across multiple requests, then move it forward into a servlet
2) If the Java code in a JSP is logic that is specific to a request, then move it back to a helper java bean
3) Certain generic services, such as validation services may be moved to helper beans, as well

I refer to this process as "Factor-Forward-Factor Back", and it can be seen visually below:

Diagram 1

Now we have servlets that handle business logic that is common across requests, such as authentication and authorization. We also have JSP pages which include very little Java code, but rather use snippets of Java along with JSP tags to interact with a helper (or worker) bean. The helper bean is simply a non-visual JavaBean that is a container for the request specific business logic, and is also responsible for adapting and validating the intermediate model for display.

As we can see, then, servlets and JSPs complement one another and are used in combination with JavaBeans in order to handle the presentation portion of a J2EE-based architecture. 

Q: How do you see Java Server Pages fitting into the framework of the Java 2
Enterprise Edition (J2EE), and Enterprise Java Beans (EJBs)? Is this going
to take the focus away from JSP (leaving it only for issues of
presentation), or will it strengthen support for JSP?

A: The purpose of JSPs is to handle the dynamic presentation portion of a J2EE-based architecture. The purpose of EJB is to provide a scalable and portable server-side component model for transactional middleware. JSP and EJB are complementary technologies that together with the other J2EE technologies provide a platform for creating open, service-based, multi-tier architectures that are scalable, secure, and transaction-based. So, JSP and EJB are not competing technologies, as each serves an important role in creating J2EE-based architectures. The following diagram shows this relationship visually.

Diagram 2

Q: Looking to the future now, where do you see Java heading? Do you think
Java will continue to make inroads with the server-side market and
eventually topple other technologies like ASP, or will ASP continue to
dominate the market?

A: Java-based technologies are clearly preferred now for new development on server-side, multi-tier Enterprise applications. Additionally, Java and XML are becoming the technologies of choice for data transformation and exchange, since Java provides platform portability while XML provides data portability. Another burgeoning area where Java is becoming a strategically enabling technology is the area of Pervasive computing. We will continue to see huge advances in this market as companies begin to build the infrastructure for wireless phones and other appliances to utilize business services on their enterprise networks. So, Java is becoming a ubiquitous technology from the smallest handheld devices to the largest Enterprise systems, and the network services in between that connect these disparate systems. 

Q: Thanks for your insight into Java Server Pages and web development Dan. Readers that would like to learn more are invited to read a sample chapter from Dan's book Professional JSP. You can also read a review of the title, which is published by Wrox Press and is available from all good bookstores, or online from

Back to main

Copyright 1998, 1999, 2000 David Reilly

Privacy | Legal | Linking | Advertise!

Last updated: Monday, June 05, 2006