I am using out.print() to print statements in JSP but can we use <%="..." %> to improve performance?
Asked
Active
Viewed 72 times
0
-
2That basically results in the same operation (compare the compiled jsps) and even if there was a performance difference it would probably be negligible. Why are you trying to improve your performance that way? If you have problems here there most certainly are other areas that can be improved with more performance gains. – Thomas Apr 12 '16 at 15:31
-
2The simple fact is that using either is an approach that went out of fashion around 15 years ago so I think you've got more to worry about than performance. http://stackoverflow.com/questions/3177733/how-to-avoid-java-code-in-jsp-files?rq=1 – Alan Hay Apr 12 '16 at 15:44
2 Answers
1
out.print is plenty efficient. The problem you are experiencing might lie somewhere else in your code.
Here is a good article on improving performance in a JSP:
http://www.precisejava.com/javaperf/j2ee/JSP.htm
cheers!

Devin Clark
- 1,078
- 11
- 9
1
http://docs.oracle.com/javaee/5/tutorial/doc/bnaov.html
When the scripting language is the Java programming language, an expression is transformed into a statement that converts the value of the expression into a String object and inserts it into the implicit out object.
I don't think there is any performance difference - once the JSP is compiled, the resulting code is effectively the same. See this answer for a bit more context on the jsp lifecycle.