接收请求并处理,再将结果返回给调用者
//返回的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;
}
}
}