国产探花免费观看_亚洲丰满少妇自慰呻吟_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://www.survivalescaperooms.com)



發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 嘉义市| 泾阳县| 盘山县| 怀化市| 焦作市| 徐州市| 通化县| 景宁| 道孚县| 阳原县| 聂拉木县| 威海市| 荆州市| 横山县| 平遥县| 齐齐哈尔市| 枝江市| 横峰县| 华坪县| 应城市| 宁南县| 观塘区| 莎车县| 合江县| 吉木乃县| 景宁| 神木县| 辉南县| 隆子县| 大悟县| 德江县| 章丘市| 阳东县| 大城县| 织金县| 翁源县| 囊谦县| 九龙城区| 泸溪县| 尚志市| 出国|