• Post Reply Bookmark Topic Watch Topic
  • New Topic

Is it not possibel to do this in JSTL  RSS feed

 
thomas colding
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Anybody can tell why following code to create a Dropdown box does not show the values correct in the list.
My intention is that the value from my request should bee selected.
All the values are prefixed with following selected<
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please UseCodeTags when posting code or configuration. Unformatted code and configuration is very difficult to read. You can edit your post to include them by using the button.
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're closing the <option> tag before you put the "selected" attribute in to it. I would have thought running the code would have highlighted this issue.

You might want to consider using a loop of some sort rather than just cutting and pasting the same code many times; doing so makes the code much easier to read, maintain, and understand.
 
thomas colding
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
David Newton wrote:You're closing the <option> tag before you put the "selected" attribute in to it. I would have thought running the code would have highlighted this issue.

You might want to consider using a loop of some sort rather than just cutting and pasting the same code many times; doing so makes the code much easier to read, maintain, and understand.



Sorry for my mistake
Do it have to be as following


<SELECT name="montno" onChange="selectChanged(this);">
<OPTION value=1<c:if test="${requestScope.numberoffmonth=='1'}">selected</c:if>>1</OPTION>
<OPTION value=2<c:if test="${requestScope.numberoffmonth=='2'}">selected</c:if>>2</OPTION>
</SELECT>



It is still the same problem selected>1
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How does the generated HTML look like? It should provide a clue to what's going on.
 
thomas colding
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ulf Dittmer wrote:How does the generated HTML look like? It should provide a clue to what's going on.


As following

 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In other words, JSTL is not working. Do you have the correct taglib directive in that page?
 
Carol Enderlin
drifter
Ranch Hand
Posts: 1364
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Have you taken a look at the JSP FAQ? El Or Jstl Not Working As Expected
 
thomas colding
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks everybody, it was a missing taglibrary, I do not understand why it is possible to save a JSP if one off taglib is missing.
It is not possible to it in Java, but thanks at all.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65833
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thomas colding wrote:I do not understand why it is possible to save a JSP if one off taglib is missing.

How could it possibly know what you intended?
 
thomas colding
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bear Bibeault wrote:
thomas colding wrote:I do not understand why it is possible to save a JSP if one off taglib is missing.

How could it possibly know what you intended?



Sorry but if I knew I had not asked
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65833
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My point was: how would it know what libraries you intended to use so it could tell you that you forgot to include them? Because namespaces are not strictly bound, it can't see the "c" namespace and assume you intended to use the JSTL core library. The "c" namespace can be bound to anything (though it'd be a poor practice to not follow conventions).
 
thomas colding
Ranch Hand
Posts: 60
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Bear Bibeault wrote:My point was: how would it know what libraries you intended to use so it could tell you that you forgot to include them? Because namespaces are not strictly bound, it can't see the "c" namespace and assume you intended to use the JSTL core library. The "c" namespace can be bound to anything (though it'd be a poor practice to not follow conventions).


Sorry again I will try to follow the restriction in the furture, I hope that by time it should be better with guidiance from all your people in this Forum.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!