• 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

passing XML between servlets in different webapps (b2b)

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi there folks,
i'm a newbie in xml, been searching high and low, didn't get what i wanted.
just a rough idea of what i wanna achieve - basically i wanna pass an xml document from ServletA to ServletB, how do i go about doing this? some sample codes on the sending part as well as the receiving(parsing) end would be greatly appreciated...
thanks and hope to hear from you guys....
cheers,
 
author
Posts: 11962
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You need to make HTTP POST requests with the XML message as the content.
For sending, you can use the Jakarta Commons HttpClient.
For parsing, just do a HttpServletRequest#getInputStream() and parse it.
If you're new to XML parsing in general, there are some nice articles at IBM developerWorks. For specific solutions, you should bookmark The Java Developer's Almanac.
 
Ranch Hand
Posts: 140
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
A possible gotcha to watchout for is not all Document implementations are Serializable. So if you change your Document implementation, make sure you check this.
 
Lasse Koskela
author
Posts: 11962
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by eammon bannon:
A possible gotcha to watchout for is not all Document implementations are Serializable. So if you change your Document implementation, make sure you check this.

Actually, I wasn't thinking about serializing a org.w3c.dom.Document object into the HTTP POST body but generating raw XML into the HTTP POST body (something like this).
If you end up using serialization, do remember to encode the resulting binary content into Base64 (or something else) for transport.
 
Damon Hill
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi guys,
thank you so much for the reply, i will look into the references which you all provided!
once again, thanks!
this forum rocks!
cheers,
 
reply
    Bookmark Topic Watch Topic
  • New Topic