aspose file tools*
The moose likes JSP and the fly likes Adding <c:if> to option tag Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "Adding <c:if> to option tag" Watch "Adding <c:if> to option tag" New topic
Author

Adding <c:if> to option tag

Eshwar Prasad
Ranch Hand

Joined: Mar 21, 2008
Posts: 202
I am using JSTL to get populate the book list to select box.

In my action class i am setting selected book name to session on submitting the form. My success page of the action is also the same input page. So I am expecting the selected book name to be selected in the drop box.


so i added the line to option tag.


But the value is not selected as expected. Please let me know if I am making any thing wrong here.
Bhoomika Bathla
Ranch Hand

Joined: Nov 28, 2009
Posts: 40
Hi,

Try changing the line number four of your jsp to following : -



Thanks
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60074
    
  65

Did you look at the generated HTML to see if it was correct?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Bhoomika Bathla
Ranch Hand

Joined: Nov 28, 2009
Posts: 40
yes i checked the source code it is showing one of the option as selected, which i select and if you are not able to get the result try printing the value of "sessionScope.selectedState".
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60074
    
  65

Bhoomika Bathla wrote:yes i checked the source code...

But you're not the one who needs to do the checking. The first step the OP should take is to check the generated HTML.
Eshwar Prasad
Ranch Hand

Joined: Mar 21, 2008
Posts: 202
Thanks Bhoomika.

@Bear- I checked the generated HTML. As the value was getting printed when not placed inside the option tag, i was confused about the syntax usage. Any ways thanks for all help.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Adding <c:if> to option tag
 
Similar Threads
How to get multi-select to display "selected" values when return to jsp page?
Problem with nested c:forEach
How to get default value to my dropdown list
LinkedHashMap Iteration problems
Loading a file content in dropdown list