• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

How to pass a parsed XML Document object from servlet to JSP??

 
Ranch Hand
Posts: 120
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I need to pass a Document Object from servlet to JSP:
I basically parse the input Stream into a doc such as::
InputStream in = urlConn.getInputStream();
DocumentBuilderFactory dbf=DocumentBuilderFactory.newInstance();
DocumentBuilder db=dbf.newDocumentBuilder();
Document doc = db.parse(in);
System.out.println("my doc "+ doc.toString()); // this gives me null???any ideas why?
I need to pass doc to template.jsp and to process the doc on the template.jsp
Thanks in advance

------------------
Sun Certified Java Programmer
Sun Certified Java Developer
I-Net Certified
A+ Certified
Network+ Certified
MCP
 
Ranch Hand
Posts: 65
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Here's a snippet of code from another program that I think does what you are looking for, perhaps it would be a useful example for you.
StringBuffer buffer = null;
parser.startDocument();
Document document = parser.getDocument();
NewsItem currentNewsItem = null;
NewsItemBuilder currentNewsItemBuilder = new NewsItemBuilder() ;
Node currentNewsItemNode = null;
currentNewsItem = (NewsItem)iterator.next();
currentNewsItemBuilder.setNewsItem(currentNewsItem);
currentNewsItemNode = currentNewsItemBuilder.getNewsItemNode(document);
document.appendChild(currentNewsItemNode);
OutputFormat of = new OutputFormat("XML","UTF-8",false);
StringWriter xmlData = new StringWriter();
XMLSerializer serializer = new XMLSerializer(xmlData,of);
serializer.serialize(document);
buffer = xmlData.getBuffer();
xmlItems[index] = buffer.toString();
Dave
------------------
David Kane
david_kane@houseofyin.com
Author of Software Architecture: Organizational Principles and Patterns
http://www.vraps.com
http://www.houseofyin.com
 
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
Thanks dave I will look over this code and I will get back to you.
Thanks in Advance
------------------
Sun Certified Java Programmer
Sun Certified Java Developer
I-Net Certified
A+ Certified
Network+ Certified
MCP
 
reply
    Bookmark Topic Watch Topic
  • New Topic