Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

generate sitemap dynamically w/o using servlet

10 views
Skip to first unread message

us...@yahoo.com

unread,
Jun 23, 2005, 9:40:56 PM6/23/05
to
I want to generate sitemap.xml dynamically when users access
http://mysite/sitemap.xml. What's the logic to do that other than
creating a servlet?

Joan

unread,
Jun 23, 2005, 10:24:38 PM6/23/05
to

<us...@yahoo.com> wrote in message
news:1119577255.9...@g43g2000cwa.googlegroups.com...

> I want to generate sitemap.xml dynamically when users access
> http://mysite/sitemap.xml. What's the logic to do that other than
> creating a servlet?

applet?


us...@yahoo.com

unread,
Jun 24, 2005, 2:52:43 AM6/24/05
to
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?).

Wendy Smoak

unread,
Jun 24, 2005, 10:52:45 AM6/24/05
to
<us...@yahoo.com> wrote

> 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.

--
Wendy Smoak


Joan

unread,
Jun 24, 2005, 12:18:01 PM6/24/05
to

"Wendy Smoak" <wsm...@gmail.com> wrote in message
news:d9h6o8$ltt$1...@news.asu.edu...

She's (Wendy) right you know.

> --
> Wendy Smoak
>
>


us...@yahoo.com

unread,
Jun 24, 2005, 2:25:49 PM6/24/05
to
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?

us...@yahoo.com

unread,
Jun 24, 2005, 2:26:20 PM6/24/05
to

Alan Krueger

unread,
Jun 25, 2005, 12:35:40 AM6/25/05
to
us...@yahoo.com wrote:
> 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.

0 new messages