接收请求并处理,再将结果返回给调用者


//返回的xml消息体(用在servlet中) 
        String  backXml = "<?xml version=\"1.0\" encoding=\"UTF-8\" ?

><root><code>0</code><name>www</name></root>";
  
 sendCompressDate(resp, backXml);
 


public static void sendCompressDate(HttpServletResponse response,
   String result)
 {
  BufferedWriter out = null;
  try
  {
   out = new BufferedWriter(new OutputStreamWriter(response
     .getOutputStream(), "UTF-8"));
   out.write(result);
   out.flush();
  } catch (IOException e)
  {
   e.printStackTrace();
  } catch (Exception e)
  {
   e.printStackTrace();
  } finally
  {
   try
   {
    if (out != null)
    {
     out.close();
     out = null;
    }
   } catch (IOException e)
   {
    out = null;
   }
  }
 }

posted @ 2013-06-14 23:19  嗨,你的益达~~~  阅读(267)  评论(0编辑  收藏  举报