| Author |
Simple Doubt
|
Vishnu Prakash
Ranch Hand
Joined: Nov 15, 2004
Posts: 1026
|
|
JSP expressions become out.print() in the _jspService() method and plain old template text becomes out.write() in the _jspService() method. I am sure the first one is correct but am not sure with the second one. Is is the second one correct.
|
Servlet Spec 2.4/ Jsp Spec 2.0/ JSTL Spec 1.1 - JSTL Tag Documentation
|
 |
Stefan Evans
Bartender
Joined: Jul 06, 2005
Posts: 1008
|
|
It is perfectly legitimate. It just saves an interim method call JspWriter extends java.io.Writer. java.io.Writer provides the method "write(String s)" Most of the print* methods will just indirectly call the writer. The print method has to be used for expressions, because you don't know the type of the argument. With template text, you know the type is String, so can use the method write. Also the print(String s) method is tasked with printing out "null" if the argument is null. As you know the argument being passed is not null, you can just call write directly. So they save an entire method call, and an if statement for every out.write() they use instead of an out.print(). Given the amount of times this happens in a JSP, it seems a worthwile optimization.
|
 |
 |
|
|
subject: Simple Doubt
|
|
|