Slashdot Mirror


Web Development With JSP

This "dynamic content" thing doesn't seem to be going away, does it? Web sites need to get smarter to handle the types of content that at least some people want to see on them these days, and the coders and designers behind them need the tools to make them so. Accordingly, Gavin Bong crafted this review of Web Development with JSP, which may be one of the tools you need.

Web Development with JSP author Duane K. Fields and Mark A.Kolb pages 543 publisher Manning rating 8.5 reviewer Gavin Bong ISBN 1884777996 summary Comprehensive coverage of JSP1.1. Suitable for beginning to intermediate Java developers.

Prologue

Before I proceed with the review, I feel obligated to respond to Jayakrishnan's review of Core Servlets and JSP and Slashdot readers' comments.

I share the sentiments of most people that the use of JSP scriptlets (Model 1) is bad practice. The mantra, "Thou shalt not mix HTML and Java code," should be tattooed onto every JSP developer's forehead. And as the author and readers have suggested, either choose a Model 1.5 (JSP or custom tags with JavaBeans) or Model 2 (MVC) to implement moderate- to high-complexity Web applications.

However, I believe that the authors of this first generation of JSP books need to inform the populace of what JSP is fully capable of (warts and all) -- in order for developers to appreciate the other paradigms. And beyond that, these authors must then educate on how not to use JSP. And I believe that will be the difference between a complete JSP book and an incomplete one.

Secondly, JSP Model 1 has been often described as "servlets lite." It is a good paradigm for prototyping servlets. For example, SOAP4J (IBM's SOAP framework) was released using a JSP scriptlet to dispatch SOAP RPC invocations. The software has since been donated to the Apache group and in the latest public release; the aforementioned JSP scriptlet is now a servlet.

So on that note, let me begin the review.

Topics covered

The book starts with a survey of precursor technologies to JSP in Chapter 1 and quickly moves into the real subject matter. It is clear from the start, that this book is written with the Java programmer in mind. I'd say that only the first five chapters are useful reading for a JSP page designer. Concepts like "How to setup a JSP/Servlet engine?", "Incorporating applets with tag," JDBC, JNDI, and EJB are either relegated to the Annexes or lightly mentioned before detailed treatment follows. The authors only cite HTML and Java as prerequisites but it's more accurate to say that readers also need to have some knowledge of core J2EE services like servlets. Here's a tip: have the JSP v1.1 and Servlets v2.2 specifications within close reach when reading the book.

The book covers all the core JSP topics; here's a sampling:

1. JSP and JavaBeans
The book provides a very readable introduction to JavaBeans for those unfamiliar with it. This is required reading for those implementing the Model 1.5 architecture. However, features specific to visual-oriented beans are not covered. Page designers should specifically devour Chapter 5 on JSP bean tags. The two notable samples provided are:
  • CachedRowSet Bean - An example of paging through results using the JDBC 2.0 RowSet interface.
  • JDBC Transaction Processing - An example of maintaining a JDBC transaction across several JSP pages using a Database Connection Bean and JSP implicit objects.
2. JSP Performance/Scalability
Performance and scalability issues are discussed accross several chapters. The authors attribute JSP's performance to servlet performance, which is tied to JVM server memory. No rule of thumb on sizing JVM server memory is given, but a tip is offered on how to use the serializable interface to estimate the size of Java objects that will be placed in the session object.

Session migration over multiple load-balanced machines is touched upon lightly but no technical details were offered. I would have liked to see a practical example on session persistence coupled with a use case of load balancing a JSP website. It's unfortunate also that the authors didn't think that database connection pooling warrants a practical example.

3. Multithreading
Throughout the book, readers are reminded to be aware of thread safety issues when dealing with shared resources (e.g. JDBC Connections). This tip is offered: "Examine all static variables & objects whose scope is session or application."

4. Exception Handling
A comprehensive coverage on how to handle exceptions in a JSP web application is provided and covers these areas:

  • Error pages in JSP
  • Null properties in JavaBeans
  • Undefined values in Database tables
  • Handling exceptions in servlets (JSP Model 2)
5. JSP Web application architectures
In Chapter 8, the page centric architecture (Model 1) is compared to a servlet centric one (Model 2). A discussion on the servlet RequestDispatcher interface culminates with a sample, that demonstrates how a servlet dictates application flow; relegating JSP pages to provide only presentation services, when called upon. A more complicated sample using this architecture is developed in Chapter 9.

6. Deployment
The book provides complete information on WAR files and Deployment Descriptors.

7. Three chapters of code samples
One full chapter is dedicated to a sample implementation of a real world example of a faq-o-matic tool. Also provided are two chapters of code snippets for Web-based functionality like form handling, cookie management and JSP's marriage with Javascript.

8. Custom tags
The last two chapters are dedicated to this very unique feature of JSP and in it they provide sample custom tags for content substitution and translation, coverage on how to package taglibs and more advanced techniques incorporating Java reflection in custom tag helper classes.

Weaknesses

The book comes with eight pages of errata - mainly spelling/naming errors in the code. I think publishers need to ensure that code be proofread as diligently as the prose. Fortunately the book has a Web site (taglib.com) with a link to a Web-based public forum.

The JSP API in Annex E is presented in the same style as Oreilly's Java in a nutshell book. A UML diagram would have been nice.

And finally, just like in the Core Servlets and JSP book; there's no mention of i18n or security. But this is probably a moot point since you gain i18n features directly from the Java language itself and the "contentType" @page directive attribute. Security of a JSP application is largely dictated by the Servlet/JSP engine configuration (albeit you can plug in your own authentication/encryption schemes) and would be better covered in a book dedicated to system administration and other deployment issues.

Is it worth buying?

It is important to mention that this book covers JSP 1.1 and Servlet 2.2, the production release of each technology. Recently JSP 1.2 and Servlet 2.3 have both entered the Proposed Final Draft stage. So the question is: should you wait for a new edition? My suggestion is: go buy the ebook version (in PDF) from Manning's website. And at a price of $16.50, that's a steal.

In terms of content, the book offers good value in its coverage of deployment issues, different JSP architectures and not forgetting some really good material on custom tags/taglibs. And by advocating an MVC styled development architecture; everyone from your JSP page designers, JavaBean/servlet developers and DBAs will be less coupled - and your code more maintainable.

Table of contents

  • Chapter 1: Introduction
  • Chapter 2: Fundamentals
  • Chapter 3: Programming JSP scripts
  • Chapter 4: Actions and implicit objects
  • Chapter 5: Using JSP Components
  • Chapter 6: Developing JSP Components
  • Chapter 7: Working with databases
  • Chapter 8: Architecting JSP applications
  • Chapter 9: An example JSP Project
  • Chapter 10: Deploying JSP applications
  • Chapter 11: Performing common JSP tasks
  • Chapter 12: JSP by example
  • Chapter 13: Creating custom tags
  • Chapter 14: Implementing advanced custom tags
  • Annex A: Running the reference implementation
  • Annex B: Incorporating Java applets
  • Annex C: JSP resources
  • Annex D: JSP syntax reference
  • Annex E: JSP API reference

Besides the PDF version, you can also purchase this book at Fatbrain.

1 of 102 comments (clear)

  1. Re:Garbage by spooge21 · · Score: 5

    You like reading Slashdot, right? Slashdot could be written in Java using JSP for page generation. This is the type of dynamic content that the author is referring to.

    I REALLY wish people would stop immediately associating Java with eye-candy applets. This is, IMHO, the weakest use for Java.

    As a server side language Java is extremely powerful, primarily due to the huge number of APIs available but also due to the basic design of the language and the core API. Java also promotes code reuse better than any mainstream language out there (once again this is my opinion).

    If you don't like Java as a server side language then don't use it. But please, stop saying Java == applets or JavaScript and using that as a reason to trash the Java platform.