Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

java.lang.ArrayIndexOutOfBoundsException ???

Status
Not open for further replies.

RicardoPereira

Programmer
Jun 3, 2003
255
PT
What should be the cause of this??

java.lang.ArrayIndexOutOfBoundsException


i have a bean that access my database, and i user this code to process a form:

<jsp:useBean id=&quot;pesquisas&quot; scope=&quot;request&quot; class=&quot;bd.AcessoBD&quot; />

<% String sXNENC = request.getParameter(&quot;XNENC&quot;); %>

<HR><center><table border=0 cellspacing=1 cellpadding=2 bgcolor = &quot;#eeeeee&quot;>
<tr bgcolor=&quot;#eeeeee&quot;><td class=&quot;smallerheader&quot;><font class=&quot;smallerheader&quot;><b>Canal de Venda</b></font></td><td class=&quot;smallerheader&quot;><font class=&quot;smallerheader&quot;><font class=&quot;smallerheader&quot;><b>Nº da Encomenda</b></font></td><td class=&quot;smallerheader&quot;><font class=&quot;smallerheader&quot;><b>Data de Expedição</b></font></td><td class=&quot;smallerheader&quot;><font class=&quot;smallerheader&quot;><b>Nº Activação</b></font></td>
<td class=&quot;smallerheader&quot;><font class=&quot;smallerheader&quot;><b>Nº Guia de Transporte</b></font></td></tr>
<%
ArrayList listaEnc=pesquisas.getNEncomenda(sXNENC);
for( int x=0;x<=listaEnc.size();x++)
{
xiol01p xiol=(xiol01p) listaEnc.get(x);
out.println(&quot;<tr bgcolor='#ffffff'>&quot; +
&quot;<td>&quot; + xiol.getXCVND() + &quot;</td><td class='smallertext'>&quot; + xiol.getXNENC() + &quot;</td>&quot; +
&quot;<td class='smallertext'>&quot; + xiol.getXDEXP() + &quot;</td><td class='smallertext'>&quot; + xiol.getXNACT() + &quot;</td>&quot; +
&quot;<td class='smallertext'>&quot; + xiol.getXNGT() + &quot;</td></tr>&quot;);

}
%>



The problem is here?

Thanks

 
What does &quot;pesquisas.getNEncomenda(sXNENC);&quot; do?
maybe this method falls into an Exception?


Salih Sipahi
Software Engineer.
City of Istanbul Turkey
s.sipahi@sahinlerholding.com.tr
 
Is i because when you access an array the first item is stored at position 0. So in your code you are going from 0 all the way up to listaEnc.Size() when you really only need to go to listaEnc.Size() - 1.

Try changing
for( int x=0;x <= listaEnc.size();x++)
to
for( int x=0;x < listaEnc.size();x++)
 
DJSmith is right.I didn't notice the loop.

Salih Sipahi
Software Engineer.
City of Istanbul Turkey
s.sipahi@sahinlerholding.com.tr
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top