I will stick with servlet. :)
So if user types http://mysite/customerlist.xml, the request goes into
the customerlist generator servlet. I have customerlist generator
function in another file to create the customerlist.xml. But how to
connect xml file with the servlet? In customerlist generator, File file
= new File (where should I specify the customerlist.xml path?).
> So if user types http://mysite/customerlist.xml, the request goes into
> the customerlist generator servlet. I have customerlist generator
> function in another file to create the customerlist.xml. But how to
> connect xml file with the servlet?
In web.xml, the same way you connect any other URL path to a Servlet.
> In customerlist generator, File file
> = new File (where should I specify the customerlist.xml path?).
If you're dynamically generating the information every time it's requested,
why write it to a File at all? Just use the 'response' object to send it
out to the client.

Signature
Wendy Smoak
Joan - 24 Jun 2005 17:18 GMT
> > So if user types http://mysite/customerlist.xml, the request goes into
> > the customerlist generator servlet. I have customerlist generator
[quoted text clipped - 9 lines]
> why write it to a File at all? Just use the 'response' object to send it
> out to the client.
She's (Wendy) right you know.
> --
> Wendy Smoak
usgog@yahoo.com - 24 Jun 2005 19:25 GMT
My home project code is like the following:
DOMSource domSource = new DOMSource(xml); //xml is a DOM tree.
File F = new File ("customerlist.xml");
TransformerFactory tff = TransformerFactory.newInstance();
Transformer serializer = new tff.newTransformer();
StreamResult srOut = new StreamResult(tff);
serializer.transform(domSource, srOut);
So I am using DOM and then serialize it to XML. So the servlet will
call this code to generate 'customerlist.xml' on the fly. So how to
connect 'response' object with srOut and then display
'customerlist.xml' out to the client without writing it to a File?
usgog@yahoo.com - 24 Jun 2005 19:26 GMT
My home project code is like the following:
DOMSource domSource = new DOMSource(xml); //xml is a DOM tree.
File F = new File ("customerlist.xml");
TransformerFactory tff = TransformerFactory.newInstance();
Transformer serializer = new tff.newTransformer();
StreamResult srOut = new StreamResult(tff);
serializer.transform(domSource, srOut);
So I am using DOM and then serialize it to XML. So the servlet will
call this code to generate 'customerlist.xml' on the fly. So how to
connect 'response' object with srOut and then display
'customerlist.xml' out to the client without writing it to a File?
Alan Krueger - 25 Jun 2005 05:35 GMT
> So I am using DOM and then serialize it to XML. So the servlet will
> call this code to generate 'customerlist.xml' on the fly. So how to
> connect 'response' object with srOut and then display
> 'customerlist.xml' out to the client without writing it to a File?
Why not just serialize the XML directly to the response stream? Writing
to a file only makes sense if you're caching the results and not
re-generating it every time.