File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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
Author

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}" />
<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

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

<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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Convert JSTL variable type