开发者

Problem encountered while using PrintWriter in Java

开发者 https://www.devze.com 2023-02-10 10:46 出处:网络
public void doGet(HttpServletRequest request,HttpServletResponse response)throws ServletException, IOException {
public void doGet(HttpServletRequest request,HttpServletResponse response)throws ServletException, IOException {
    PrintWriter out = response.getWriter();
    out.println("Hello World");
  }

Does Fine But if instead of "Hello World", if a large String(String object with huge chunk of data ) is used, then nothing gets printed in the browser , in fact, no ex开发者_JAVA百科ception or error is thrown either. Did any one encounter such a scenario?


PrintWriters don't throw exceptions. Use checkError() to test whether something went wrong (unfortunately it doesn't tell you what went wrong).

Write directly into the output stream (response.getOutputStream()) and catch exceptions to get more details.

0

精彩评论

暂无评论...
验证码 换一张
取 消