Beginner,help needed with JSTL.

Hello,

I just started on JSP.I have a simple code to query a table:

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

<%@ taglib prefix="sql" uri="http://java.sun.com/jsp/jstl/sql" %>

<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>

<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>

<sql:setDataSource var="example" scope="application"

driver="oracle.jdbc.driver.OracleDriver"

url="jdbc:oracle:thin:@192.168.2.1:1521:oracle"

user="xyz"

password="abc"

/>

<sql:query var="empDbInfo" dataSource="${example}">

select * from ss.emp

</sql:query>

<table>

<tr>

<c:forEach items="${empDbInfo.columnNames}" var="colName">

<th><u>${fn:escapeXml(colName)}&nbsp&nbsp&nbsp</u></th>

</c:forEach>

</tr>

<c:forEach items="${empDbInfo.rowsByIndex}" var="row">

<tr>

<c:forEach items="${row}" var="column">

<td>${fn:escapeXml(column)}</td>

</c:forEach>

</tr>

</c:forEach>

</table>

--

The table has been define in "ss" schema within oracle.This is the result of same query in SQL Plus:

select * from ss.emp;

N NAME

1 h

The output html that I get is just:

NNAME

and no values.

Why dont the values come?I;ve tried different things,but no luck..please help me on this.Thanks.

[1608 byte] By [SHivina] at [2007-10-2 16:50:20]
# 1

What do you see when you view source on the generated page?

Does it produce the <tr> tags?

Does it produce <td> tags?

Try generating some HTML comments, and then view source.

<!-- starting the forEach loop -->

<c:forEach items="${empDbInfo.rowsByIndex}" var="row" varStatus="status">

<!-- row ${status.count} -->

<tr>

<c:forEach items="${row}" var="column">

<td>${fn:escapeXml(column)}</td>

</c:forEach>

</tr>

</c:forEach>

There were {fn:length(empDbInfo.rowsByIndex)} rows returned.

Hope this helps,

evnafets

evnafetsa at 2007-7-13 18:01:55 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2
Thanks for the reply.Actually,there was a problem in user permission.I set all permissions for user "SYSTEM" and the selection worked fine.Whats wierd is that through SQL PLUS,I could do the selection without any problems,and thus couldn't understand where the problem lay.
SHivina at 2007-7-13 18:01:55 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...