Mark Watson’s Artificial Intelligence Books and Blog

Share this post

Why I love Java: somethings are so easy to do...

markwatson.com

Why I love Java: somethings are so easy to do...

Mark Watson
Jun 11, 2004
Share

I am working on a GPLed web-based knowledge management system, and this morning I wanted to add an administrative task: downloading all data (about users, projects, etc., but not the actual content being managed: Word, OpenOffice, PDF, etc. documents) for backup purposes.

I can't believe how easy it was to write (back to the user's PC) a zip output stream containing compressed XML files (one XML file per business class):

1. I used Brendan Macmillan's utility to write plain old Java objects to an XML stream. I wrapped this in class ArchiveToXml to save all business data objects
2. In a JSP page, I added 3 lines:

response.setContentType("application/zip");

response.setHeader("Content-disposition", "attachment; filename=\"alldata.xml\"");

new ArchiveToXml().saveData(response.getOutputStream());


Something that I thought might take a few hours, took 30 minutes - love it!

Share
Comments
Top
New

No posts

Ready for more?

© 2023 Mark Watson
Privacy ∙ Terms ∙ Collection notice
Start WritingGet the app
Substack is the home for great writing