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:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
<HTML>
<BODY>
<FORM METHOD="post" ACTION="/servlet/bbs.CompoundJSPController">
<P>Please complete the form.</P>
<P>board
<BR>
<INPUT TYPE="text" NAME="board" ID="board" SIZE="20"
MAXLENGTH="20">
</P>
<INPUT TYPE="hidden" NAME="mlname" ID="mlname" VALUE="HTML">
<P>
<INPUT TYPE="submit" NAME="Submit" ID="Submit" VALUE="Submit">
&nbsp;
<INPUT TYPE="reset" NAME="Reset" ID="Reset" VALUE="Reset">
&nbsp;
</P>
</FORM>
</BODY>
</HTML>
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 java.io.*;
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