Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Convert JSTL variable type

 
Dhiraj Srivastava
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi I m using the following simple code..

<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>
<c:forEach var="i" begin="1" end="10" step="1">
<c ut value="${i}" />
<br/>
</c:forEach>

and it is working perfectly. I want to convert this JSTL variable "i" in the JSP primitive type.
like

<% out.println(i)%>

How can I do this... Thanks in advance
 
Dhiraj Srivastava
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What I want to get the ${i} value in a primitive data type. Like in int.
e.g getting the ${i} in a integer say in i or j

How can do this. ... Its urgent
 
alan do
Ranch Hand
Posts: 354
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i haven't found a way to do this. jstl has automatic type coercion though (see specs appendix). perhaps your problem can be solved (if you care to explain in details further) with more JSTL and not necessarily finding out how to get the jsp primitives from JSTL values.
 
Dhiraj Srivastava
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
See this what I exactly wants

<sql:query var="Emp" sql="SELECT * FROM EmpList" dataSource="${example}"> </sql:query>

<%-- Get the column names for the header of the table --%>

<TABLE BORDER=1>
<c:forEach var="columnName" items="${Emp.columnNames}">
<th><c ut value="${columnName}"/></th>
</c:forEach>

<%-- Get the value of each column while iterating over rows --%>

<c:forEach var="row" items="${Emp.rows}"> <tr>
<c:forEach var="column" items="${row}"> <td><c ut value="${column.value}"/></td> </c:forEach> </tr>


As you can see on this JSP page I am getting some data from the data base. Now I want to amend the JSTL variables like getting the values from ${Emp.rows} in an array.

I hope you understand

Thanks
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic