一个Servlet基础题,大家来帮我看看
编写一个Servlet程序,在方法中显示一个表单,用户可以输入姓名和电子邮件地址,用户提交该表单后,在方法中动态地读出请求参数,并输出这些参数.
package thirdservlet;
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
import java.util.*;
/**
* <p> Title: </p>
*
* <p> Description: </p>
*
* <p> Copyright: Copyright (c) 2007 </p>
*
* <p> Company: </p>
*
* @author not attributable
* @version 1.0
*/
public class ThirdServlet extends HttpServlet {
private static final String CONTENT_TYPE = "text/html; charset=GBK ";
//Initialize global variables
public void init() throws
ServletException {
}
//Process the HTTP Get request
public void doGet(HttpServletRequest request, HttpServletResponse response) throws
ServletException,
IOException {
response.setContentType(CONTENT_TYPE);
PrintWriter out = response.getWriter();
String username = request.getParameter( "username ");
String useremail = request.getParameter( "useremail ");
if(username == null||useremail == null) {
out.println( " <html> ");
out.println( " <head> <title> ThirdServlet </title> </head> ");
out.println( " <body bgcolor=\ "#ffffff\ "> ");
out.println(
" <form method=\ "post\ " action=\ "/ServletModuel/ThirdServlet\ "> ");
out.println( " <table border=\ "0\ " width=\ "80%\ " align=\ "center\ "> ");
out.println( " <tr> <td height=\ "80\ "> 姓名 </td> ");