PrintWriter out = response.getWriter()

在servlet里

PrintWriter out = response.getWriter()

从HttpServletResponse中get一个PrintWriter,取一个响应客户端的流对象

打个通俗的比方就是通过HttpServletResponse对象得到一支笔,然后就可以用out.print()方法在网页上写任何你想显示的内容。
out.print("<html><body>");
out.print("任何内容");
out.print("</body></html>");

通过PrintWrite,以流方式输出html,返回给客户端,显示在IE上。

最后 out.close(); 关闭流

猜你喜欢

转载自4636.iteye.com/blog/2328735