先感谢大家的帮助啊
这个是index
<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>
这个是用来处理html输入的servlet
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>");
}
}
当我send后,显示这个错误信息
HTTP Status 500 -
type Exception report
message
description The server encountered an internal error () that prevented it from fulfilling this request.
exception
java.io.CharConversionException: Not an ISO 8859-1 character: 输
javax.servlet.ServletOutputStream.print(ServletOutputStream.java:89)
javax.servlet.ServletOutputStream.println(ServletOutputStream.java:242)
FormServlet.doPost(FormServlet.java:21)
javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
note The full stack trace of the root cause is available in the Apache Tomcat/6.0.29 logs.