Java Reference
In-Depth Information
</TR>
<% for (int _i=0; _i < ShowThreadCommand.getSize(); _i++) { %>
<TR> <TD><%=ShowThreadCommand.getSubject(_i) %></TD>
<TD><%=ShowThreadCommand.getAuthor(_i) %></TD>
<TD><%=ShowThreadCommand.getPostText(_i) %></TD>
</TR>
<% } %>
</TABLE>
<P>
<A href="../JSP/reply.jsp?parent=<%=ShowThreadCommand.getParent() %>&
board=<%=ShowThreadCommand.getBoard(0) %>&
subject=<%=ShowThreadCommand.getSubject(0)%>" >
Post a reply to this message</A>
</BODY>
</HTML>
This
JSP
is nearly identical to
ShowBoardResults.jsp
. We also provide a link to
reply.jsp
. To maintain the conversation state, we pass parameters for the
board and subject.
5.2.4
Building the model, view and controller for AddPost
The final elements of our message board are the input form called
reply.jsp
and the
AddPostCommand
and
AddPostController
that we use to add a post.
The AddPost input view
Here is the input form
reply.jsp
:
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" content="text/html>
</HEAD>
<BODY>
<FORM METHOD="post" ACTION="/servlet/bbs.AddPostController">
<P>Please enter your post.</P>
<P>
<table>
<tr>
<td> Board: </td>
<td> <b><%=request.getParameter ("board") %></b></td></tr>
<tr>
<td> Subject: </td>
<td><INPUT TYPE="text" NAME="subject"
value="<%=request.getParameter ("subject") %>" ID="subject"
SIZE="50" MAXLENGTH="50" ></td></tr>
In this case, we are using the
value
parameter to prepopulate the subject field.
This technique demonstrates the power of the
JSP
. We are easily parsing the
input parameters without any complex code.