Java Reference
In-Depth Information
In this chapter, we have explored a relic from the bio labs of the past in which
a single 10 KB script is attached to the Magic Pushbutton. Alas, the disease has
escaped again. These days, a 10 KB servlet is attached to the magic Submit
pushbutton. We have the antibiotic to kill this bug. We have applied the old
Model-View-Controller command pattern to this new technology to form the
Triangle . This design pattern uses HTML as the incoming view, which calls a
servlet called the interaction controller to get incoming requests, call the cor-
responding models, and return pages. The interaction controller calls the com-
mand bean or stateless session bean to access the model, and returns one of
several JSP pages as the outgoing view. This design pattern greatly simplifies
maintenance for Java server-side programs, and it provides the foundation for
J2EE architectures.
Antipattern in this chapter
This is the template for the antipattern that appears in this chapter. It provides
an excellent summary format and forms the basis of the cross-references in
appendix A.
The Magic Servlet
R ELATED ANTIPATTERNS : Spaghetti Code, Monolithic Servlet. This anti-
pattern is the servlet-based version of Spaghetti Code. The JSP version of
this antipattern is the Monolithic Servlet.
D ESCRIPTION : The Magic Servlet is a Java servlet that does all of the work
itself. The servlet has elements of model, view, and controller. Servlets
created in this form should be approached with extreme prejudice: they
are simply evil.
M OST FREQUENT SCALE : Application to enterprise. In most cases, this
antipattern will be developed in more than one application, because one
application is used as a template for others.
S OLUTION ALSO KNOWN AS : Model 2, Modified Model-View-Controller.
R EFACTORED SOLUTION DESCRIPTION : The solution for this problem is a
version of Model-View-Controller known as the Triangle design pattern.
Because web applications are batch oriented instead of interactive, we
Search WWH ::

Custom Search