Todd Chaffee wrote:

>
> I am serializing to implement persistence.  Considering your point above,
> any suggestions on a 'better' way to do this?  My first thought was a flat
> file and then I realized that serializing the bean would be more portable
> and a more 'java' way of doing it but maybe I'm heading down the wrong path
> altogether.
>

Right now, the servlet spec doesn't help you any on persistence -- it only offers
you a "temporary" directory that is not guaranteed to survive a server restart.
There was quite a bit of discussion on the expert group responsible for the servlet
2.3 spec about supporting "writeable resources" in some fashion, but no consensus
was reached in time for the spec to be published.  Until this is addressed in the
spec, the advice is to use external mechanisms (databases, directory servers,
files, EJBs, etc.) to implement persistence.

Using serialized JavaBeans in disk files certainly fits that category -- my only
caution was that you cannot necessarily assume there is such a thing as a WEB-INF
*directory*, although many servlet containers do the same thing that Tomcat does
and expands WAR files.

One approach that would avoid portability problems would be to define a context
initialization parameter in your web.xml file, whose value is the name of a
directory that this app is allowed to use for persistent storage.  That way, you
would not be hard coding any assumptions about *where* these files are into the
applications that use them, and you could move them to a different place (say,
because a disk was getting full), with only a single configuration file change.

Craig McClanahan



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, email: [EMAIL PROTECTED]

Reply via email to