[jdom-interest] is this an appropriate use of JDOM?

Chris Todd ctodd at alabanza.com
Mon Sep 11 18:05:40 PDT 2000

Hello everyone-

I wanted to seek the opinions of JDOM users to make sure an idea I have
about how to use JDOM is not stupid.  ;-)  I hope you will forgive my
naivete, but I am a bit of a newbie to both Java and XML.

We are converting a Perl/PHP-based web application to Java (probably using
just servlets and perhaps JSP, but not using EJB).  This web app needs to
have a multi-lingual interface.  Our current implementation of this is
hideously inefficient and lingustically horrid, and I was hoping JDOM would
help.  ;-)

Here is the basic idea:

Our app only has about 50 or so 'pages', the text of which rarely ever
changes.  The text of these pages would be in XML documents, possibly one
document per page, with the translation for each language within appropriate
XML tags (e.g.
	<Greeting> Hello! </Greeting>
	...other document tags here...
	<Greeting> Bon Jour! </Greeting>
	...other document tags here...

This XML document would be parsed into a JDOM object (probably one JDOM
object per language per page), and these objects would live in memory all
the time.  We would do that by instantiating one of these objects from each
servlet that serves up one 'page' of our app, and given the servlet life
cycle, both the servlet and the JDOM object would live in memory (please
feel free to correct me if I misunderstand the servlet life cycle; also, I
believe this is an example of the 'singleton' design pattern?).

When a servlet for a particular page gets called by a particular user, a
session variable (probably set by the login servlet) would indicate which
language to use, and the servlet would then obtain the appropriate JDOM
object and render it into HTML via XSLT (after doing other interesting work
like querying a database, etc.).

My questions are these:
1)  Am I just loopy, or does this make sense?
2)  Will I actually gain the performance advantages I think i can gain from
having my translations live in memory as JDOM objects?
3)  Do I understand the servlet life cycle correctly...can I actually have
my JDOM object live in memory for extended periods of time?

I know Java has resource bundles that are designed to handle I18N issues,
but from what I have seen, this would lead to translations on a
phrase-by-phrase basis, which we currently do, and have been roundly
criticized for it by our translators.  Our translators would much prefer
translating an entire document at a time, something that appears easy to do
with the XML document approach.

Finally, I know these sorts of issues are exactly what Cocoon was designed
for, but Cocoon really is major overkill for what we are doing.  I think (am
I wrong) that it would be fairly simple for us to create a home-grown
solution to our problem.

Thank you in advance for any comments or advice you provide, and for taking
time to help out a newbie.  ;-)

Sincerest regards,
Chris Todd

More information about the jdom-interest mailing list