Win a copy of Practice Tests for OCP Java 17 Certification Exam (1Z0-829) this week in the OCPJP forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Rob Spoor
  • Junilu Lacar
  • paul wheaton
Saloon Keepers:
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Carey Brown
  • Scott Selikoff
Bartenders:
  • Piet Souris
  • Jj Roberts
  • fred rosenberger

Convert JSTL variable type

 
Ranch Hand
Posts: 49
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Ranch Hand
Posts: 354
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic