java - How to use if statements in templates templates.jsp? -
what problem in code... i've tried lot of solutions, error in if loop ..
<script type="text/template" id="tableitempageview"> <% if(%>${pagecontext.request.userprincipal.name } === <@= table.user @><%){ %> <td><@= table.id @></td> <td><@= table.name @></td> <td><@= table.changed @></td> <td><@= table.description @></td> <td class="correctuser"><a href="#tables/edit/<@=table.id@>">edit </a><a href="#tables/show/<@=table.id@>"> players</a><a id="removetable"> delete</a> <% }else{ %> <td><@= table.id @></td> <td><@= table.name @></td> <td><@= table.changed @></td> <td><@= table.description @></td> <% } %> </script>
on solution have 1 error , after "if" have error "syntax error on token "(", look expected after token".
i want check registered user same user created table...
i suggest utilize javaserver pages standard tag library or expression language instead of scriplet
more easy utilize , less error prone.
use implicit object available in jsp access attribute scope.
use if
core tag library
<c:if test="${requestscope.userprincipal.name == ’xyz’}"> ... </c:if>
or utilize when/otherwise
core tag library equivalent java switch statement
<c:choose> <c:when test="${requestscope.userprincipal.name == ’xyz’}" > ... </c:when> <c:otherwise> ... </c:otherwise> </c:choose>
java jsp servlets
No comments:
Post a Comment