下面介绍一个HTTP Servlet处理POST方式的例子,见示例14-3。
【程序源代码】
1 // ==================== PRogram Description ==========================
2 // 程序名称:示例14-3 : SurveyExample.Html
3 // 程序目的:SurveyExample源代码
4 // ==============================================================
5 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
6 <html>
7 <head>
8 <title>javaUsageSurvey</title>
9 </head>
10
11 <body bgcolor=#ffffff>
12 <p><img src=http://www.supcode.com/Article/html/4/43/2005/02/10/images/BEA_Button_Final_web.gifalign=right>
13 <blockquote>
14 <font face="helvetica">
15 <form action="SurveyServlet" method=POST>
16 <input type=hidden name=survey value=Survey01Results>
17 <BR><BR>How Many Employees in your Company?<BR>
18 <BR>1-100<input type=radio name=employee value=1-100>
19 <BR>100-200<input type=radio name=employee value=100-200>
20 <BR>200-300<input type=radio name=employee value=200-300>
21 <BR>300-400<input type=radio name=employee value=300-400>
22 <BR>500-more<input type=radio name=employee value=500-more>
23 <BR><BR>General Comments?<BR>
24 <BR><input type=text name=comment>
25 <BR><BR>What IDEs do you use?<BR>
26 <BR>JavaWorkShop<input type=checkbox name=ide value=JavaWorkShop>
27 <BR>J++<input type=checkbox name=ide value=J++>
28 <BR>Cafe‘<input type=checkbox name=ide value=Cafe‘>
29 <BR><BR><input type=submit><input type=reset>
30 </form>
31 </font>
32 </blockquote>
33 </body>
34 </html>
【程序输出结果】
在客户端IE浏览的效果如图14-5所示。
screen.width-600)this.style.width=screen.width-600;"图14-5 客户端浏览效果