Java Reference
In-Depth Information
<% for (int _i=0; _i < ShowThreadCommand.getSize(); _i++) { %>
<TR> <TD><%=ShowThreadCommand.getSubject(_i) %></TD>
<TD><%=ShowThreadCommand.getAuthor(_i) %></TD>
<TD><%=ShowThreadCommand.getPostText(_i) %></TD>
<% } %>
<A href="../JSP/reply.jsp?parent=<%=ShowThreadCommand.getParent() %>&
board=<%=ShowThreadCommand.getBoard(0) %>&
subject=<%=ShowThreadCommand.getSubject(0)%>" >
Post a reply to this message</A>
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.
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 :
<META HTTP-EQUIV="Content-Type" content="text/html>
<FORM METHOD="post" ACTION="/servlet/bbs.AddPostController">
<P>Please enter your post.</P>
<td> Board: </td>
<td> <b><%=request.getParameter ("board") %></b></td></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.
Search WWH ::

Custom Search