创建HTTPSERVLET的基本步骤
创建HttpServlet的基本步骤
A.导入包:
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
B.继承HttpServlet类:
public class ××× extends HttpServlet
C.覆盖doPost()、doGet()方法:
public void doPost(HttpServletRequest request,HttpServletResponse response)
throws IOException,ServletException{…}
public void doGet(HttpServletRequest request,HttpServletResponse response)
throws IOException,ServletException{…}
D.获取请求参数:
String param1 = request.getParameter();
E.创建输出对象:
PrintWriter out = response.getWriter();
F.设置响应类型:
response.setContentType();
G.输出响应内容:
out.println();
来自:http://blog.csdn.net/pengpenglin
posted on 2012-10-25 10:58 ellisonDon 阅读(679) 评论(0) 编辑 收藏 举报