Bug 54314 - Code generation of TagPlugins: When and Otherwise error when they are used without <c:choose> outside
Summary: Code generation of TagPlugins: When and Otherwise error when they are used wi...
Status: RESOLVED INVALID
Alias: None
Product: Tomcat 7
Classification: Unclassified
Component: Jasper (show other bugs)
Version: trunk
Hardware: PC All
: P2 normal (vote)
Target Milestone: ---
Assignee: Tomcat Developers Mailing List
URL:
Keywords:
Depends on: 54242
Blocks:
  Show dependency tree
 
Reported: 2012-12-17 07:05 UTC by Sheldon Shao
Modified: 2013-01-03 21:17 UTC (History)
0 users



Attachments
Patchs for Choose When & Otherwise (2.09 KB, text/plain)
2012-12-17 07:05 UTC, Sheldon Shao
Details
Test case for Choose.java, When.java & Otherwise.java (3.25 KB, text/plain)
2012-12-17 07:06 UTC, Sheldon Shao
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Sheldon Shao 2012-12-17 07:05:13 UTC
Created attachment 29773 [details]
Patchs for Choose When & Otherwise

There is no "}" when "<c:when> or <c:otherwise>" are used without <c:choose> outside. 
For example,

<c:choose>
  <c:when test="${true}">
    When 1
    <c:when test="${abc}"> When 2 </c:when>
    <c:otherwise>
       Otherwise
    </c:otherwise> <!-- These two tags will generate code like this "if ($abc}) {} else {",  no "}" at the end" -->
  </c:when>
</c:choose>
Comment 1 Sheldon Shao 2012-12-17 07:06:22 UTC
Created attachment 29774 [details]
Test case for Choose.java, When.java & Otherwise.java
Comment 2 Sheldon Shao 2012-12-17 07:12:49 UTC
The test case depends the helper class provided in Bug 54242.
Comment 3 Konstantin Kolinko 2012-12-17 09:39:39 UTC
Your JSP is incorrect. You are not allowed to nest those tags that way.

Did you expect that to be allowed, or you do not like how this error is handled?
Comment 4 Sheldon Shao 2012-12-17 15:51:05 UTC
The JSP works very well on Jasper when without tagPlugins.
However JSP can't be compiled when with those jstl TagPlugins.

Here is the original tags,

                      <c:choose>
                         <c:when test="${iqModel.lotSize gt 0}">
                            <c:when test="${iqModel.remainQty eq 1}">${res:content2(res.content.global.ViewItemWeb.ItemQuantity.LmtlotAvailable, quantityContentContract)}</c:when>
                             <c:otherwise>${res:content2(res.content.global.ViewItemWeb.ItemQuantity.LmtlotsAvailable, quantityContentContract)}</c:otherwise>
                         </c:when>
                         <c:otherwise>${res:content2(res.content.global.ViewItemWeb.ItemQuantity.LmtQtyTxt, quantityContentContract)}</c:otherwise>
                     </c:choose>


(In reply to comment #3)
> Your JSP is incorrect. You are not allowed to nest those tags that way.
> 
> Did you expect that to be allowed, or you do not like how this error is
> handled?
Comment 5 Christopher Schultz 2012-12-20 20:10:16 UTC
Sheldon, what /should/ the result be when you improperly-nest these tags?
Comment 6 Sheldon Shao 2012-12-21 07:51:13 UTC
No tagPlugins the JSP works very well. 
With tagPlugins setup should not give compilation error even at some corner case.

(In reply to comment #5)
> Sheldon, what /should/ the result be when you improperly-nest these tags?
Comment 7 Mark Thomas 2013-01-03 21:17:33 UTC
The page is invalid. When and Otherwise are required to have Choose as an immediate parent. If the JSTL implementation doesn't enforce that then that isn't Tomcat's problem.