1、一个简单的servlet程序
(1)web.xml
<servlet>
<servlet-name>youdefinedservletname</servlet-name>
<servlet-class>youtargetactionpath(example:com...)</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>youdefinedservletname</servlet-name>
<url-pattern>/xxx.do</url-pattern>
</servlet-mapping>
(2)
action继承自HttpServlet
重写doPost、doGet
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {}
(3)
返回的数据json格式
PrintWriter out=response.getWriter();
JSONObject obj=new JSONObject();
obj.put("thekey","thevalue");
String str=obj.toString();
out.print(str);
(4)
访问路径为:http://ip:port/youprojectname/xxx.do即可访问
2、http请求
(1)GET请求 POST请求
请参考http://www.cnblogs.com/nick-huang/p/3859353.html
(2) 利用HttpClient请求(参考WSClient.java代码)
对于http请求的返回状态码请参考http://blog.csdn.net/zhangmengleiblog/article/details/52513227
----------------------未完待续