wood burning stoves
The moose likes JSP and the fly likes Convert JSTL variable type Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "Convert JSTL variable type" Watch "Convert JSTL variable type" New topic

Convert JSTL variable type

Dhiraj Srivastava
Ranch Hand

Joined: Aug 29, 2001
Posts: 49
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}" />

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

<% out.println(i)%>

How can I do this... Thanks in advance
Dhiraj Srivastava
Ranch Hand

Joined: Aug 29, 2001
Posts: 49
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

Joined: Apr 14, 2005
Posts: 354
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.

-/a<br />certified slacker...yes, my last name is 'do' - <a href="http://www.luckycouple.com" target="_blank" rel="nofollow">luckycouple.com</a>
Dhiraj Srivastava
Ranch Hand

Joined: Aug 29, 2001
Posts: 49
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 --%>

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

<%-- 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

I agree. Here's the link: http://aspose.com/file-tools
subject: Convert JSTL variable type
It's not a secret anymore!