0

Hello I'm susing jstl foreach an have the follow query:

<sql:query var="calendario" dataSource="jdbc/pro-level">
                    SELECT DISTINCT 
                    (select equipo.nombre from equipo where codigo=partidos.equipo1)as eq1, 
                    (select equipo.nombre from equipo where codigo=partidos.equipo2)as eq2, 
                    torneo.nombre as Torneo, 
                    partidos.cancha,
                    partidos.ronda,
                    partidos.equipo1 as ceq1, 
                    partidos.equipo2 as ceq2 
                    FROM 
                    partidos 
                    INNER JOIN equiposdeltorneo 
                    ON partidos.equipo1 = equiposdeltorneo.equipoCodigo 
                    INNER JOIN equipo
                    ON equiposdeltorneo.equipoCodigo = equipo.codigo 
                    INNER JOIN torneo 
                    ON partidos.idTorneo = torneo.idTorneo 
                    INNER JOIN cancha 
                    ON partidos.cancha = cancha.numeroCancha 
                    WHERE torneo.idtorneo = 11 AND partidos.ronda = 1
                </sql:query>

the problem is in the foreach

<c:forEach var="row" items="${calendario.rows}" varStatus="vs">

when I try ${row} the ceq1 and ceq2 does not exists I think this is for aliases. Somebody knows why??

skaffman
  • 398,947
  • 96
  • 818
  • 769

1 Answers1

-1

Guess this is a bug .. found a similar stack overflow question .. check the below link for post with answer.

I think it as a bug may be it is a feature not provided .

the below link provides a detail how to call column names ... (just the heading names of every coloumn).

How to access duplicate column names with JSTL sql:query?

But i would suggest to use rowbyindex instead of rows.

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

and print it out like this:

<c:out value="${row[0]}"/>

just like an array the value get stored from 0 to the number of selected coloumn's.

Community
  • 1
  • 1
avinash v p
  • 531
  • 2
  • 8
  • 15