Java Reference
In-Depth Information
set (rather than get) the board attribute, and add a check so that if the user
specifies the name of a board with no posts, he or she can make another choice.
First, the input form:
<FORM METHOD="post" ACTION="/servlet/bbs.CompoundJSPController">
<P>Please complete the form.</P>
<INPUT TYPE="text" NAME="board" ID="board" SIZE="20"
<INPUT TYPE="hidden" NAME="mlname" ID="mlname" VALUE="HTML">
<INPUT TYPE="submit" NAME="Submit" ID="Submit" VALUE="Submit">
<INPUT TYPE="reset" NAME="Reset" ID="Reset" VALUE="Reset">
There is no magic here. This input form will collect a board name and invoke
our controller. The “action” tag specifies our interaction controller. In this
case, it will be invoked with an HTTP POST that will call our doPost method
instead of the doGet method from our previous example. Next, we have our
interaction controller:
package bbs;
// Imports
import javax.servlet.*;
import javax.servlet.http.*;
// Import for commands used by this class
import bbs.CompoundJSPCommand;
We will import the command for this example. We are using the Triangle
design pattern outlined in chapter 3.
public class CompoundJSPController
extends javax.servlet.http.HttpServlet
implements Serializable {
Search WWH ::

Custom Search