File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes EJB and other Java EE Technologies and the fly likes Transfer XML object from server to client Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Transfer XML object from server to client" Watch "Transfer XML object from server to client" New topic

Transfer XML object from server to client

Elena Taube

Joined: Dec 06, 2005
Posts: 21
Hi everyone,
my client should create the XML files and save it on the hard drive. As the information that should be written in the XML file is on the server, my server (one EJB) will perform the XML- creation operation. I am planning to use JDOM for XML creation.
After the xml object is created the server returns it to the client.

My question is: What type (String, org.jdom.Document, OutputStream or etc.) is the better to use for transfer the XML object from the server to client?
Thanks a lot for your help!
Mark Spritzler

Joined: Feb 05, 2001
Posts: 17276

I am confused. If the data that goes into the XML file is on the server side, why doesn't the Server side create the XML File?

I don't think the different types of return type makes much of a difference. You could create the File on the server and send that over. The difference of any of the types is kind of really small.


Perfect World Programming, LLC - iOS Apps
How to Ask Questions the Smart Way FAQ
Elena Taube

Joined: Dec 06, 2005
Posts: 21
Hi Mark,

Thanks a lot for your fast answer.
The xml file should be saved (on hard drive) on the client. That is my problem.

But I�m not sure, if it is a good idea to generate XML on the server.

1. XML file generate on the client.
The client receives the information from the server and use it for the XML generation.

2.XML file generate on the server.
The server generate XML and transfer it to the client as one object. But what object can I use to transfer?

I�m not sure if the using of the JDOM is a good idea. I am thinking about to create it with StringBuffer or with
How do you think about it?
Thank a lot!
Masoud Kalali
Ranch Hand

Joined: Jul 08, 2004
Posts: 531

it mostly depends on your design to wether generate the XML on the server or in the client.
if you generate XML on the server you introduce some loads on your server depend on how much sophesticated is your XML generation.

if you generate xml on clients you may have un-ceneteralized buziness logic , incase that you change something in the server that affect the xml generation you must update all clients.

I would use StringBuffer to create the xml , as it sounds your xml is not such sophisticated , using an string buffer (imho) is much speedier than using DOM to create XML.

you can transfer the xml content to client (in case that you generate it in server) in a simplest possible objet , as simpler your object is your serialization will be simpler and faster.

Masoud Kalali
Software Engineer - My Weblog - GlassFish Security
I agree. Here's the link:
subject: Transfer XML object from server to client
It's not a secret anymore!