Java - Un cable porfavor! java.util.NoSuchElementExceptio

 
Vista:

Un cable porfavor! java.util.NoSuchElementExceptio

Publicado por pandoro (8 intervenciones) el 13/06/2007 20:38:52
Hola amigos toy haciendo una pagina en java y jsp y ahora resulta ke me sale un error y no se como solucionarlo.

El codigo es este:

[CODE]Collection c = (Collection)request.getAttribute("listar_dades_botiga");
Iterator i = c.iterator();

int cant = Integer.parseInt(request.getAttribute("cantidad").toString());

Collection c2 = (Collection)request.getAttribute("listar_dades_pedidos");
Iterator i2 = c2.iterator();

Collection c3;
Iterator i3;
DadesEmpresaVO vo3;
boolean noborrada=false;

while (i.hasNext()) {
DadesBotigaVO vo = (DadesBotigaVO)i.next();

DadesPedidosVO vo2 = (DadesPedidosVO)i2.next();

c3 = (Collection)request.getAttribute("listar_dades_empresa");
i3 = c3.iterator();
%>
<tr>
<td align='center'><%=vo.getNIFBotiga() %></td>
<td align='center'><%=vo.getNomBotiga() %></td>
<td align='center'><%=vo.getDireccio() %></td>
<td align='center'><%=vo.getServeiOf() %></td>
<td align='center'><%=vo.getCiutatB() %></td>
<td align='center'><%
while (i3.hasNext()) {
vo3 = (DadesEmpresaVO)i3.next();
if(vo2.getNIFEmpresaP().equals(vo3.getNIFEmpresa())){
%><%=vo3.getNomEmpresa() %><%
noborrada=true;
}
}
if(!noborrada){
%><font face='Trebuchet MS' color='#FF0000'>Empresa borrada</font><%
}
%></td>
</tr>
<% } %>[/CODE]

La cuestion es ke esto busca en tres tablas unos valores, bueno cuando tengo 2 o mas tuplas en esas tablas funciona bien pero cuando solo tengo 1 tupla me da este error: java.util.NoSuchElementException.

Tengo otro codigo ke es para cuando tengo una tupla solo:

[CODE]DadesPedidosVO vo2=(DadesPedidosVO)request.getAttribute("listar_dades_pedidos");[/CODE]

Pero lo he puesto aki dentro de un if para cuando solo haya uno pero entonces este funciona bien pero el otro de collection me dice ke no tiene valores... **

if(cant!=1){ //cant contiene la cantidad de tuplas
vo2 = (DadesPedidosVO)i2.next(); //del collection **
}else{
vo2=(DadesPedidosVO)request.getAttribute("listar_dades_pedidos"); //de una sola tupla
}

Alguien me puede echar un cable?

Un saludo.
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder