JspWriter writes against print

I am developing some custom JSP tags. In my SimpleTag.doTag() I take the JspContext and call getOut() to get the JspWriter . When writing JspWriter , what is different from write(String) and print(String) ? Should I call one and not the other?

+6
java jsp jsp-tags
source share
2 answers

The print () method can buffer, the write () method inherits from the Writer class and cannot - therefore, you can get better performance from the JspWriter print () method.

In addition, the print () method is overloaded to accept many different types of objects as an argument, while the write method only deals with strings and characters.

See JspWriter javadocs for more details .

+9
source share

from javadoc:

The write function was inherited from java.io.writer.

Print function: prints "null" if the argument was zero. Otherwise, string characters are written to the JspWriter buffer or, if not used, directly to the main writer.

+3
source share

All Articles