Java Reference
In-Depth Information
public void doGet(
HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException {
performTask(request, response);
}
}
The rest of the controller is just like our previous examples. Our command
bean has changed slightly. Our board attribute is a single string instead of a
vector, with a new set method and a revised get :
protected String board = null;
public String getBoard() {
return board;
}
The execute must change to reflect the modified query and the revised
attribute type. Only the differences are shown here:
public void execute() {
...
result =
statement.executeQuery(
"SELECT subject, author, board from posts where board = '"
+ getBoard() + "'");
while (result.next()) {
subject.addElement(result.getString(SUBJECT_COLUMN));
author.addElement(result.getString(AUTHOR_COLUMN));
}
...
So far, this balloon is flying smoothly. We have addressed our separation of
concerns and stayed true to our base design pattern. Listing 4.2 contains the
revised JSP . Unfortunately, we are in for a hard landing. This response set is
just like our last, with an additional page for a not-found condition.
Listing 4.2
The compound JSP processes decisions in the JSP
<HTML>
<jsp:useBean id="CompoundJSPCommand" class="bbs.CompoundJSPCommand"
scope="request"></jsp:useBean>
<% if (CompoundJSPCommand.getSize() == 0) { %> B Decision 1
<HEAD>
<TITLE>Choose another board! </TITLE>
</HEAD>
<p>
Search WWH ::




Custom Search