posts - 0, comments - 77, trackbacks - 0, articles - 356
            BlogJava :: 首頁 :: 新隨筆 :: 聯系 :: 聚合  :: 管理

          日歷

          <2025年6月>
          25262728293031
          1234567
          891011121314
          15161718192021
          22232425262728
          293012345

          隨筆分類

          隨筆檔案(1)

          收藏夾(18)

          搜索

          •  

          最新評論

          ajax struts url stream

          Posted on 2007-07-04 11:54 semovy 閱讀(364) 評論(0)  編輯  收藏 所屬分類: struts

          public class Example7Action extends Action {


            public ActionForward execute(ActionMapping mapping, ActionForm inForm, HttpServletRequest request, HttpServletResponse response) throws Exception {

              String feedURL = (String)request.getParameter("feedURL");

              if (feedURL == null || feedURL.equalsIgnoreCase("")) {
                return null; // Trivial error handling... if no URL sent in, essentially do nothing
              }
              feedURL = new URLCodec().decode(feedURL);

              // Go get the feed
              StringBuffer xml = new StringBuffer(4096);
              try {
                URL               u   = new URL(feedURL);
                InputStream       in  = u.openStream();
                InputStreamReader isr = new InputStreamReader(in);
                BufferedReader    br  = new BufferedReader(isr);
                String theLine;
                while ((theLine = br.readLine()) != null) {
                  xml.append(theLine);
                }
              } catch (Exception e) {
                System.err.println("Example7Action Exception: " + e);
              }

              // Write the XML to response
              response.setContentType("text/xml");
              PrintWriter out = response.getWriter();
              out.println(xml);
              out.flush();

              return null;

            } // End execute()


          }

          主站蜘蛛池模板: 沙洋县| 武威市| 神农架林区| 双鸭山市| 屏南县| 洞头县| 郧西县| 铜山县| 巴南区| 镇康县| 塔河县| 峡江县| 民和| 岳普湖县| 湟源县| 和静县| 遵化市| 偏关县| 晋城| 宣武区| 达尔| 金堂县| 兴山县| 长兴县| 海林市| 安阳县| 财经| 德兴市| 海丰县| 东兰县| 博野县| 嘉禾县| 金溪县| 监利县| 黄大仙区| 新邵县| 镶黄旗| 尚义县| 贺兰县| 交口县| 汕头市|