I'm developing some custom JSP tags. In my SimpleTag.doTag()
I grab the JspContext
and call getOut()
to get the JspWriter
. When writing to JspWriter
, what's the different between write(String)
and print(String)
? Should I be calling one instead of the other?
The print() method can buffer, the write() method is inherited from the Writer class and cannot - so you may get better performance from the JspWriter's print() method.
In addition, the print() method is overloaded to take many different types of objects as an argument, whereas the write method deals in Strings and chars only.
See the JspWriter javadocs for more details.
from the javadoc:
The 'write' function was inherited from java.io.writer .
The 'print' function: prints "null" if the argument was null. Otherwise, the string's characters are written to the JspWriter's buffer or, if no buffer is used, directly to the underlying writer.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With