android访问web工程,并解析web工程返回的xml文件
如题:
首先建立一个简单的web工程,使用servlet技术:
下面是servlet的实现。
[html]
/**
* @FILE:ListServlet.java
* @AUTHOR:Administrator
* @DATE:2013-5-19 下午6:03:19
**/
package com.yehui.servlet;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.yehui.service.VideoNewsService;
import com.yehui.service.bean.News;
import com.yehui.service.impl.VideoNewsServiceImpl;
/*******************************************
*
* @CLASS:ListServlet
* @DESCRIPTION:
* @AUTHOR:Administrator
* @VERSION:v1.0
* @DATE:2013-5-19 下午6:03:19
*******************************************/
public class ListServlet extends HttpServlet {
private VideoNewsService service = new VideoNewsServiceImpl();
/**
* The doGet method of the servlet. <br>
*
* This method is called when a form has its tag value method equals to get.
*
* @param request
* the request send by the client to the server
* @param response
* the response send by the server to the client
* @throws ServletException
* if an error occurred
* @throws IOException
* if an error occurred
*/
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
doPost(request, response);
}
/**
* The doPost method of the servlet. <br>
*
* This method is called when a form has its tag value method equals to
* post.
*
* @param request
* the request send by the client to the server
* @param response
* the response send by the server to the client
* @throws ServletException
* if an error occurred
* @throws IOException
* if an error occurred
*/
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
List<News> videos = service.getLastNews();
request.setAttribute("videos", videos);
// ("")里面是jsp的文件路径
request.getRequestDispatcher("/WEB-INF/page/videonews.jsp").forward(request, response);
}
}
/**
* @FILE:ListServlet.java
* @AUTHOR:Administrator
* @DATE:2013-5-19 下午6:03:19
**/
package com.yehui.servlet;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import com.yehui.service.VideoNewsService;
import com.yehui.service.bean.News;
import com.yehui.service.impl.VideoNewsServiceImpl;
/*******************************************
*
* @CLASS:ListServlet
* @DESCRIPTION:
* @AUTHOR:Administrator
* @VERSION:v1.0
* @DATE:2013-5-19 下午6:03:19
*******************************************/
public class ListServlet extends HttpServlet {
private VideoNewsService service = new VideoNewsServiceImpl();
/**
* The doGet method of the servlet. <br>
*
* This method is called when a form has its tag value method equals to get.
*
* @param request
* the request send by the client to the server
* @param response
* the response send by the server to the client
* @throws ServletException
* if an error occurred
* @throws IOException
* if an error occurred
*/
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
doPost(request, response);
}
/**
* The doPost method of the servlet. <br>
*
* This method is called when a form has its tag value method equals to
* post.
*
* @param request
* the request send by the client to the server
* @param response
* the response send by the server to the client
* @throws ServletException
* if an error occurred
* @throws IOException
* if an error occurred
*/
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
List<News> videos = service.getLastNews();
request.se
补充:移动开发 , Android ,