Franz Kafka
Franz Kafka

Reputation: 10831

Persistence without database web ideas

I am developing a java web software with jsf in a team. We don't want to use a database, but want the persistence done by simple files on the filesystem. Please don't ask why and say that it is stupid, because it is in most cases.

We can't really say something like D:/data or /home/user/data is the place to put the data, because maybe someone is using windows, mac or linux.

Is there some standard way of saving files through the application server that will survive a restart and maybe even a redeployment of the app, update of the server and so on - real persistence? If not, is there a tomcat solution?

Upvotes: 0

Views: 805

Answers (3)

Kevin
Kevin

Reputation: 56059

A few suggestions:

  1. If the data you need to store is small enough, do it in a cookie.

  2. Prompt the user for a file. If you don't want to ask for a new/existing file every time, store the path in a cookie.

  3. Try accessing the home directory in the unix, mac, and windows formats and see which one works.

I would say if 1 doesn't work, you should use 2 because you really shouldn't write to the user's drive (especially from an applet) without their knowledge.

Upvotes: 0

mschor
mschor

Reputation: 141

You're trying to save files on the server side or the client side?

If it's the server side, then you would have control over the OS (unless of course you are deploying the app server to each user and they'll be running it locally...), but the way I take your question I think you're proposing to store data on the client side. In that case you may want to use a cookie as long as you're not storing sensitive data.

Upvotes: 0

The standard does not provide access to a location in the file system where a web application can have read/write access to arbitrary files.

You can, however, designate a location and pass in the location through a system property or a property file.

If you just want to have user information available with session scope, then consider putting serializable objects in the session and let the container manage it.

Upvotes: 4

Related Questions