What is the advantage (if there is one) of using a custom action instead of a scriptlet?
For example, which is better in a performance context?
<c:if test="${param.Clear}">
<font color="#ff0000" size="+2"><strong>
You just cleared your shopping cart!
</strong><br> <br></font>
</c:if>
or
<%if (param.Clear){%>
<font color="#ff0000" size="+2"><strong>
You just cleared your shopping cart!
</strong><br> <br></font>
<%}%>
I have a big JSP project and I want to know if is necessary to use tag libraries or if I can keep my Java scriptlets.
Also, I want to implement custom tags for some things that now are separate JSP files with Java, JavaScript, CSS, and HTML code.
As far as performance goes, they both get compiled down to servlets, so they should perform equally well.
There doesn't seem to be much to recommend JSTL in the example you give, but what happens to projects I've seen is code like:
<%if (param1.Clear() && param2.isSomeFlagSet() && !param3.isSomeOtherFlagSet()){%>
<font color="#ff0000" size="+2"><strong>
You just cleared your shopping cart!
</strong><br> <br></font>
<%}%>
and it gets copied all over. >_< If you replace this with JSTL mechanically you can get something just as bad, obviously, but it gives you an opportunity to organize things better.
Follow BalusC's advice and get rid of inline Java code from your JSPs where you can.
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