Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / June 2005

Tip: Looking for answers? Try searching our database.

generate sitemap dynamically w/o using servlet

Thread view: 
usgog@yahoo.com - 24 Jun 2005 02:40 GMT
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 - 24 Jun 2005 03:24 GMT
> 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?
usgog@yahoo.com - 24 Jun 2005 07:52 GMT
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 - 24 Jun 2005 15:52 GMT
> 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.


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.