Developing and Testing JSPs in WSAD





Developing and Testing JSPs in WSAD

In Chapters 6 and 7, you saw how to develop servlets to add dynamic behavior to your Web application. Servlets work well, but at the end of Chapter 7, we explored some difficulties in using servlets alone. Developing good dynamic HTML is hard. Getting the content right, making it look good, and getting HTML to do what you want can be quite difficult. It's even harder when the HTML is buried in Java print statements. In the Java editor, there's no WYSIWYG design view, no HTML content assist, no preview, quotes on attribute values have to be escaped, etc.

When servlets are used to create user interface components consisting of dynamic HTML pages, it's the HTML that is the primary focus, not Java. JSPs allow you to focus on the dominant language, HTML, making the development process much simpler.

Another problem we discussed was mixing control logic and user interface look and feel. By separating these concerns, we can develop JSPs that focus only on the user interface, making them simpler to develop, easier to test, and more reusable. We also discussed error handling which is a special case of separating control logic from user interface page design. In the servlet implementation, we had to catch exceptions and output different HTML based on the exception. JSPs offer a different solution by allowing us to specify error pages directly avoiding all the extra code.

In this chapter, we'll return to the example we developed in Chapter 7 and reimplement some of the servlets as JSPs. In doing so, we'll use the indirect development model based on MVC to provide better separation of user interface, controller, error handling, and model code as shown in Figure. We'll also introduce the components of WSAD that support JSP development, deployment, and testing. As in Chapter 7, we'll do this by introducing the tools in the context of developing the example JSP-based application.

1. Architectural road map.

graphics/13fig01.gif


     Python   SQL   Java   php   Perl 
     game development   web development   internet   *nix   graphics   hardware 
     telecommunications   C++ 
     Flash   Active Directory   Windows