编写处理请求参数的 Servlet

编写处理请求参数的 Servlet,代码如下:

package servlet;

import java.io.*;

import javax.servlet.*;

import javax.servlet.http.*;

public class CheckParamServlet  extends HttpServlet{

/**

 *

 */

private static final long serialVersionUID = 1L;

 

public void doGet(HttpServletRequest request,

 HttpServletResponse response)

 throws ServletException, IOException {

 String name = request.getParameter("name");

 String pass = request.getParameter("pass");

 response.setContentType("text/html;charset=gb2312");

 PrintWriter out = response.getWriter();

 

 out.println("<html><head><title>Param Test</title></head>");

 out.println("<h3 align=center>你的用户名为:"+name+"</h3>");

 out.println("<h3 align=center>你的口令为:"+pass+"</h3>");

 out.println("</body></html>");

 }

 

 public void doPost(HttpServletRequest request,

 HttpServletResponse response)

 throws ServletException, IOException {

 

 doGet(request,response);

 }

}

阅读更多
换一批

没有更多推荐了,返回首页