国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 學院 > 開發設計 > 正文

發送XML文件

2019-11-18 16:07:07
字體:
來源:轉載
供稿:網友
import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.PRintWriter;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class ResourceServlet extends HttpServlet {

  public void doGet(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {

    //get web.xml for display by a servlet
    String file = "/WEB-INF/web.xml";

    URL url = null;
    URLConnection urlConn = null;
    PrintWriter out = null;
    BufferedInputStream buf = null;
    try {
      out = response.getWriter();
      url = getServletContext().getResource(file);
      //set response header
      response.setContentType("text/xml");

      urlConn = url.openConnection();
      //establish connection with URL presenting web.xml
      urlConn.connect();
      buf = new BufferedInputStream(urlConn.getInputStream());
      int readBytes = 0;
      while ((readBytes = buf.read()) != -1)
        out.write(readBytes);
    } catch (MalformedURLException mue) {
      throw new ServletException(mue.getMessage());
    } catch (IOException ioe) {
      throw new ServletException(ioe.getMessage());
    } finally {
      if (out != null)
        out.close();
      if (buf != null)
        buf.close();
    }
  }
  public void doPost(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {

    doGet(request, response);
  }
}

(出處:http://m.survivalescaperooms.com)



發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 琼中| 乾安县| 五寨县| 长兴县| 微山县| 武胜县| 南宁市| 长汀县| 玉环县| 新晃| 子长县| 安平县| 横山县| 尚义县| 察隅县| 日喀则市| 成武县| 灵宝市| 贵南县| 贺兰县| 云浮市| 甘肃省| 安乡县| 阳高县| 太原市| 宝坻区| 闵行区| 芮城县| 大港区| 启东市| 深泽县| 锡林郭勒盟| 治县。| 隆回县| 宿松县| 温泉县| 泽普县| 沙河市| 寿宁县| 辽宁省| 正宁县|