• Post Reply Bookmark Topic Watch Topic
  • New Topic

populating jsp page from document object works for one but not multiple elements  RSS feed

 
Ray Smilgius
Ranch Hand
Posts: 120
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
see code below:::
here is the xml string
<MAIN><RESPONSE><PAGE>success.jsp</PAGE></DATA><ITEM>This is the first item</ITEM><ITEM>This is the second item</ITEM><ITEM>This is the third one</ITEM></DATA><ERROR></ERROR></RESPONSE></MAIN>
the code below works find for displaying the <PAGE>success.jsp</PAGE> but I need to display all three items in<ITEM></ITEM> in the browser.

Any Suggestions Thanks

<%@page import="javax.xml.parsers.DocumentBuilderFactory,java.net.*,java.io.*,javax.xml.parsers.DocumentBuilder,org.w3c.dom.*" %>

<%!Document doc;%>
<html>
<head>
<title>My first template</title>
</head>
<body>
<%
doc = (Document)request.getAttribute("theDOM");
NodeList nameItems=doc.getElementsByTagName("PAGE");
out.print("Length (" + nameItems.getLength() + ")" + "<br>");
for(int i=0;i<nameItems.getLength();i++)
{
String Itemvalue=nameItems.item(i).getFirstChild().getNodeValue();
out.print("Item Data as follows (" + Itemvalue + ")" + "<br>");
}
%>
<br>The Data Response from IDS</br>
<br><h2><font color=#DB1260>Congrats Successful Login Welcome to Success</font></h2></br>
</body>
</html>
Thanks in advance

------------------
Sun Certified Java Programmer
Sun Certified Java Developer
I-Net Certified
A+ Certified
Network+ Certified
MCP
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I didn't read the whole thing, but the way you declared the Document object makes it an instance variable for JSP and is therefore not Thread-safe (unsafe when accessed by multiple threads).
As an initial step, try declaring it in a scriptlet rather than a declaration block.
Dave.
 
Ray Smilgius
Ranch Hand
Posts: 120
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Good point.
I will change that now.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!