文档介绍:Tomcat 上如何部署Servlet及Android中如何与服务器通信
下载Tomcat并安装
Apache Tomcat powers numerous large-scale, mission-critical web applications across a diverse range of industries anizations. Some of these users and their stories are listed on the PoweredBy wiki page.
Apache Tomcat, Tomcat, Apache, the Apache feather, and the Apache Tomcat project logo are trademarks of the Apache Software Foundation.
I add this English description due to junk baidu wenku`s rules
Eclipse中编写Servlet代码:创建java工程
.;
import ;
import ;
import ;
import ;
import ;
import ;
import ;
import ;
.;
.;
public class WebserviceTest extends HttpServlet {
private static final long serialVersionUID = 512;
private List<Student> list;
protected void doPost(HttpServletRequest req,HttpServletResponse response) throws ServletException,IOException{
doGet(req, response);
}
protected void doGet(HttpServletRequest req,HttpServletResponse response) throws ServletException,IOException{
("test/plain");
("UTF-8");
PrintWriter outPrintWriter = ();
JSONArray jsonArray = new JSONArray();
list = initData();
for(Student bean:list) {
JSONObject jsonObject = new JSONObject();
try{
("stunum", ());
("name",());
("chinese", ());
("math", ());
("english", ());
}catch (Exception e) {
();
}
(jsonObject);
}
(());
();
();
}
private List<Student> initData(){
List<Student> studentlist= new ArrayList<Student