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

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!

Comments

Popular posts from this blog

Ruby Sinatra web apps with background work threads

My Dad's work with Robert Oppenheimer and Edward Teller

Time and Attention Fragmentation in Our Digital Lives