
Hi My code always show arrayindexoutofbound
here is my code i am using arraylist to display and DOM parser to retrieve XML value. I am searching the value by attributes equals 2.
this error i am getting. org.apache.jasper.JasperException: An exception occurred processing JSP page /lab04/extra-classes/Dom2.jsp at line 65
62: { 63: %> 64:
java.lang.IndexOutOfBoundsException: Index: 1, Size: 1
for(int index=0; index < nodeList.getLength(); index++)
{
%>
<tr>
<td><%=getStat_list(nodeList).get(index)%></td>
<td>hsbjdjsbdjd<%=getStat_list(nodeList).size()%></td>
</tr>
<%
}
%>
<%!
public ArrayList <String> getStat_list(NodeList tripnode)
{
ArrayList<String>vector = new ArrayList<String>();
for(int index=0; index < tripnode.getLength(); index++)
{
Node node = tripnode.item(index);
NamedNodeMap attrs = node.getAttributes();
if(attrs.getNamedItem("id").getNodeValue().equals("2"))
{
if(node.getNodeType() == Node.ELEMENT_NODE)
{
Element element = (Element) node;
//Attr attribute = (Attr) attrs.item(index);
NodeList nameNode = element.getElementsByTagName("title");
for(int iIndex=0; iIndex< nameNode.getLength(); iIndex++)
{
if(nameNode.item(iIndex).getNodeType() == Node.ELEMENT_NODE)
{
Element nameElement = (Element) nameNode.item(iIndex);
vector.add(nameElement.getFirstChild().getNodeValue().trim());
}
}
}
}
}
return vector;
}
%>
</table>

Please visit the following link:
http://www.roseindia.net/jsp/RetrievingDataFromTheXmlFile.shtml
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.