日期:2014-05-17 浏览次数:20820 次
<HTML>
<HEAD>
<TITLE>
CHECKBOX
</TITLE>
</HEAD>
<BODY>
<FORM action="here" method="POST">
UserName:<INPUT TYPE="TEXT" SIZE="30" MAXLENGTH="15"><BR>
Password:<INPUT TYPE="PASSWORD" SIZE="30" MAXLENGTH="3"><BR>
<HR>
CHECKBOX:
<INPUT TYPE="CHECKBOX" NAME="CHECKBOX1">CHECK1
<INPUT TYPE="CHECKBOX" NAME="CHECKBOX2">CHECK2
<INPUT TYPE="CHECKBOX" NAME="CHECKBOX3">CHECK3
<INPUT TYPE="CHECKBOX" NAME="CHECKBOX4">CHECK4
<INPUT TYPE="CHECKBOX" NAME="CHECKBOX" CHECKED>
<HR>
RADIO:
<INPUT TYPE="RADIO" NAME="RADIO1" VALUE="1">RADIO1
<INPUT TYPE="RADIO" NAME="RADIO2" VALUE="2">RADIO2
<INPUT TYPE="RADIO" NAME="RADIO3" VALUE="3">RADIO3
<HR>
MENU:
<SELECT NAME="SPORTS">
<OPTION VALUE="FOOTBALL" SELECTED>FOOTBALL</OPTION>
<OPTION VALUE="BASKETBALL" SELECTED>BASKETBALL</OPTION>
<OPTION VALUE="TENNIS" SELECTED>TENNIS</OPTION>
</SELECT>
<HR>
TEXTAREA:
<TEXTAREA NAME="TEXT" ROWS="4" COLS="30"></TEXTAREA>
<HR>
<INPUT TYPE="SUBMIT" VALUE="SENDo">
<INPUT TYPE="RESET" VALUE="CLEAR">
</FORM>
</BODY>
</HTML>
import java.io.*;
import java.util.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class FormServlet extends HttpServlet{
protected void doGet(HttpServletRequest request,
HttpServletResponse response) throws ServletException, IOException {
doPost(request,response);
}
protected void doPost(HttpServletRequest request,HttpServletResponse response) throws IOException{
Enumeration keys;
String key;
String value;
response.setContentType("text/html");
ServletOutputStream out = response.getOutputStream();
out.println("<html><head>nihao</head><body>");
keys = request.getParameterNames();
out.println("Servlet:<br>");
while(keys.hasMoreElements()){
key = (String)keys.nextElement();
value = request.getParameter(key);
out.println("<p>"+key+"="+value);
}
out.println("</body></html>");
}
}