I have a method in my servlet where I have some prints to the console..
private void collectingWorkPositions(HttpSession session, HttpServletRequest request)
{
System.out.println("Collecting1..");
//code...
System.out.println("Collecting2..");
//code...
System.out.print("printing p: ");
for(Integer i:p)
System.out.print(i + " ");
}
When this method iscalled, only
Collecting1..
Collecting2..
are printed in the console. When I am refreshing the JSP page, only then the last print (without the ln) isprinted. I know that the difference between these two is that println
will print on a new line where print
will print at the same line, so why is this not happening here in the same action ?
This is related to the fact you never terminate the line. This is either something to do with java not flushing, or to do with the log handler waiting until the end of line before writing to the log.
Add a final
System.out.println()
orSystem.out.print('\n')
at the end to fix it.