Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

JSTL nesting values?  RSS feed

 
Edna Earhart
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have the below code in a jsp page -- what I am trying to do is very common in that based on what a user previous selected in a menu(select) widget I need to then show that selected value in the menu again if the user submits the page and then is returned to the same page if there is an error condition(save the state) - my problem is I do not know how to achieve this as essentially I think I need to nest user.id within the test"${} condition - the below code does not work as user.id is not evaluating correctly? I am sure you must be able to do this somehow in jstl - I am just not familiar enough with jstl syntax -- I am using <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> tablib.

<select name="objectName" id="objectId>
<c:forEach var="user"items="${users}">

<option value="${user.id}"
<c:if test="${formBean.userId == user.id }">selected</c:if> > ${user.name}
</option>

</c:forEach>
</select>

Thanks very much
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 66205
151
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please take the time to choose the correct forum for your posts. This forum is for questions on HTML and JavaScript.

For more information, please read this.

This post has been moved to a more appropriate forum.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!