Java Reference
In-Depth Information
String subject = postList.getSubject(i);
String author = postList.getAuthor(i);
String board = postList.getBoard(i);
out.println("<TD>" + subject + "</TD>\n");
out.println("<TD>" + author + "</TD>\n");
out.println("<TD>" + board + "</TD>\n");
Notice the loop that generates our dynamic content. The database origins of
our data are no longer visible at all. The Command pattern has effectively iso-
lated the model so that the implementation can change unencumbered.
} catch (Throwable theException) {
The remainder of the method simply closes our HTML constructs and
catches the exception. Overall, this example is simpler and more direct than
its counterpart.
Now, our program has a basic model, an HTML view on the client, and a
servlet that has some “view” logic in the form of print statements, as well as
some “controller” logic that takes a request, invokes our command, and gets
the result. To clean up our implementation, we need to take the print state-
ments out of the servlet. We will do this with a mechanism known as the JSP .
Separating the return trip
At this point, we will deviate slightly from the traditional model-view-control-
ler architectures. Internet-related user interfaces are batch oriented. Model-
view-controller user interfaces are interactive. We have two distinct communi-
cations in our model: the initial request and the return trip. Because we
dynamically build our return page, it needs to be explicitly represented in our
architecture. This is exactly what we have done in figure 3.6.
To continue to refactor this solution, we will next break out the return trip.
This portion of code builds the HTML page that is returned to the user. To do
this, we are going to use a JSP .
A JSP is a server-side derivative of HTML . JSP s allow Java code and pointers
to dynamic content to be added to a server-side page, in addition to all of the
Search WWH ::

Custom Search