Java Reference
In-Depth Information
B This section handles the classic not-found condition. We drop into Java to make a
decision and specify which interface to present.
C This section handles the mainline condition. The conditional logic is very distract-
ing to the mainline processing.
The readability is diminished. None of the HTML editors that I used liked the
structure. My intuition says that many designers would not have a problem
understanding our structure, but each additional enhancement would con-
tinue to break down our separation of concerns. In general, Java code in a JSP
should be used only for:
Accessing commands
Basic looping
Handling simple cosmetic output conditions, like adding an ā€œsā€ to
make words plural
That's it. If you need convincing, find a ColdFusion shop that has had to
maintain a complex site for two years. You'll be scared straight. I was.
4.3.3
Solution: Split the JSP
In our revised solution, we'll split the Compound JSP into two files and move
the decision point into the controller. Our command will not change.
Figure 4.2 shows a solution that improves readability, preserves our separation
of concerns, and is infinitely more toolable (easily supported by development
products and tools).
4.3.4
Making decisions in the controller servlet
In our updated example, the command does not change. Listing 4.3 contains
the updated method in our controller. The last seven lines now process the
decision that was previously handled in our JSP . We lose very little readability,
in spite of the additional complexity.
Listing 4.3
Decisions are moved to the controller servlet
public void performTask(
HttpServletRequest request,
HttpServletResponse response) {
try {
String board=request.getParameter ("board");
CompoundJSPCommand postList = new CompoundJSPCommand();
postList.setBoard(board);
Search WWH ::




Custom Search