Hi,

In article <[EMAIL PROTECTED]>,
Thu, 19 Jan 2006 09:51:37 +0530,
"214060 - Shou Jiesong" <[EMAIL PROTECTED]> wrote: 
214060> public void doGet(HttpServletRequest request,
[snip]
214060>         response.setContentType("text/html");
214060> 
214060>         PrintWriter out = response.getWriter();
214060> 
214060>         out.print("<html><head><title>Testing Servlets</title>" +
214060> 
214060>                 "</title></head><body><h1>Count is " + count +
214060> 
214060>                 "</h1></body></html>");
214060> 
214060>         out.close();

In this context, PrintWriter#close() method commits the response body,
and then, subsequent output (i.e. print method calls) will be ignored.


214060> I observed that the test failed. I called doGet() twice and it was
214060> suppose to increase count to 2. it does in testDoGet() since I could see
214060> the printed result; it was 2.
214060> 
214060> But in endDoGet(), the count was always 1 whatever how many times
214060> doGet() was called in testDoGet().

If you want test if the count is properlly incremented,
you might set the session attribute before doGet() method get called.
For example:
          Integer prevCount = new Integer(1);
          session.setAttribute("Count", prevCount);
          doGet(request, response);

Hope this helps,
----
Kazuhito SUGURI

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to