直接使用System.out.println()

或者System.err.println() 就行



  1. protectedvoid doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {  

  2. // TODO Auto-generated method stub

  3.        System.out.println("现在的时间是:"+new Date());  

  4.        response.setContentType("text/html;charset=UTF-8");  

  5.        response.setCharacterEncoding("UTF-8");  

  6.        PrintWriter out = response.getWriter();  

  7.        String now = "现在的时间是:";  

  8.        now += new SimpleDateFormat("yyyy年MM月dd日 HH时mm分ss秒E").format(new Date());  

  9.        System.out.println(now);

  10.        out.println(now);   //返回给客户端,println长的一样.

  11.        out.flush();  

  12.    }