• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

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

 
Ranch Hand
Posts: 120
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Good point.
I will change that now.
 
Yeah, but does being a ninja come with a dental plan? And what about this tiny ad?
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic