That's correct.I am new to struts. I have a question regarding logic tag. I was replacing those if.... else if ..... end if stuffs with logic tags on jsp pages. For example:
if num==1 {// condition 1 block 1; }else if num==2 {// condition 2 block 2; }
Usually if condition 1 is true, condition 2 does not be evaluated. Now if I use <logic:equal> tag as follows: <logic:equal ........> (condition 1) block 1; </logic:equal.....> <logic:notEqual ....> (condition 2) block 2; </logic:notEqual>
It seems that condition 2 is always evaluated no matter what the result of condition 1 is.
It would be a performance penalty if this is the case. Am I wrong?It is basically not possible to directly model an if-then-else clause using XML syntax. The best approach I've seen is the one used in JSTL, where the <c:choose> tag acts like a "switch" statement in Java or C:
<c:chose> <c:when test="...test for condition 1..."> ... condition 1 results ... </c:when> <c:when test="...test for condition 2..."> ... condition 2 results ... </c:when> <c:otherwise> ... equivalent to a final else with no condition ... </c:otherwise> </c:choose>
On the other hand, does a "performance penalty" particularly matter, even if it exists? If you're using JSP pages the way that Struts suggests, you would only be using conditionals in the page to choose which elements to render, probably based on some very simple conditional tests, and the only thing your using is a little extra CPU on the web tier (which is very rarely the bottleneck for performance in an overall system).
I would generally suggest that you code for clarity and maintainability first, and then worry about peephole optimizations like this only if it turns out that your app is not fast enough, and indeed that doing something about this particular case will actually make any difference.
Thanks for help,
Kathy
Craig
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]