In my servlet I gave both out.print and out.write. but both prints in the browser.
out.print
out.write
What is the exact difference between these two and when
The basic difference is that out.write() explodes if you pass it a null:
out.write()
String s = null; out.print(s); // outputs the text "null" out.write(s); // NullPointerException