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 to use out.print and out.write ?
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
2.1m questions
2.1m answers
60 comments
57.0k users