In-depth analysis of the difference between out. print and out. write in Jsp, out. printout. write
The out object in jsp is of the JspWriter type.
JspWriter inherits java. io. Writer.
The write method is defined in the parent class Writer,
The print method is defined in the subclass JspWriter.
The reload print method can convert various types of data into strings for output.
The overloaded write method can only output character-related data such as character/character arrays/strings. if the two methods are used to output a null String object, the print method outputs "null", and the write method throws an NullPoiterException.
Out. write () is a byte output stream method.
Out. print () is the method of character output stream
In jsp, The out isHttpServletResponse. getWriter (),
Is the character output stream
So most of them use print
The above is a small Editor introduced to you in Jsp out. print and out. the difference between write and I hope it will be helpful to you. If you have any questions, please leave a message. The editor will reply to you in time!