1

Using jstl I want to list each letter of the alphabet.

I want something like a b ... z

Joe
  • 7,922
  • 18
  • 54
  • 83
  • In Java: http://stackoverflow.com/questions/2578233/how-do-i-get-the-set-of-all-letters-in-java-clojure – assylias Mar 26 '12 at 17:44

3 Answers3

5
<c:set var="alphabet" value="A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z" />
<c:forTokens var="letter" items="${alphabet}" delims=",">
    ${letter}
</c:forTokens>
louwiet
  • 51
  • 1
  • 2
2

Ok, no scriptlet. How about a JSP expression? If you don't want either of them, then you can create a custom EL function. Look near bottom of Hidden features of JSP/Servlet

<%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>  
<c:forEach var="i" begin="97" end="122">
    <%=Character.toChars((Integer)pageContext.getAttribute("i"))%>
</c:forEach>
Community
  • 1
  • 1
rickz
  • 4,324
  • 2
  • 19
  • 30
1

Assuming you can inject java directly in (I don't know JSTL) you could do this

for(char letter = 'a'; letter <= 'z'; letter++) {
    System.out.println(letter + " ");
}

keeping in mind that a char is just an unsigned integer.

corsiKa
  • 81,495
  • 25
  • 153
  • 204
  • I am not allowed to inject Java scriptlets directly in the code. I'm not saying it is a reasonable restriction, but it is the restriction I am working under. – Joe Mar 26 '12 at 17:58