Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

storing data without using a database.

 
Saurabh Agarwal
Greenhorn
Posts: 23
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sir/mam

I have to take data from a form and then store that data without using a database.
now, again when user inserts next record...same servlet is called which stored earlier record....so the problem is how can i persist previous record and store next record in servlet because every time the servlet is called whole record previously stores is refreshed.

I dont hav to use a database....
Do i need to use sessions here...so that it can persist data on same servlet calls.....

tx in advace...
 
Nitesh Kant
Bartender
Posts: 1638
IntelliJ IDE Java MySQL Database
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Welcome to JavaRanch!

You may not have read our naming policy on the way in. It requires that you use a full, real (sounding) first and last name for your display name. Funny "handles" aren't acceptable here. You can change your display name here. Thanks!

As to your question, i do not think its very clear.
You want to store the data on a physical storage? I am asking this because you mentioned that you can use session.
What is the data that is to be stored? What are the operations that you will do on the data i.e read only, read + modify.
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13046
6
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have to take data from a form and then store that data without using a database.


The simplest way to provide storage of data that lasts longer than a user session and survives when the server is off is to use Java object serialization to a file. It is up to the programmer to come up with a naming and location convention for the file.

You might use a custom Java object or just use one of the collection classes. See the java.io package JavaDocs for ObjectOutputStream and ObjectInputStream. Once you have a naming and locating convention in place, the rest is pretty simple.

Bill
 
Nitesh Kant
Bartender
Posts: 1638
IntelliJ IDE Java MySQL Database
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The simplest way to provide storage of data that lasts longer than a user session and survives when the server is off is to use Java object serialization to a file.


Yeah thats correct, but it comes with problems that arise due to the class version changes. Your application, if required, must be capable of handling the same.
Other way could be to serialize it as an xml file, so that it can be read by programs written in languages other than java. Also, it will be easy to migrate these to a new scheme if class/data definition changes. It all depends on the requirement that you have.
 
Rahul Bhattacharjee
Ranch Hand
Posts: 2308
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You may want to store the data in a simple text file as well as name value pairs.

But it again depends on the kind of data that you want to store and importance of that data , any anticipated changes to the data storage method.
 
Amit Kumargupta
Ranch Hand
Posts: 54
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Its depends on the what kind of data you storing....
 
Carl Trusiak
Sheriff
Posts: 3340
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My answer, use a database!!! If you don't have one configured for you, utilize something like Derby in the embedded mode. This will store your data to the file system for you and allow the easy capability of growing your application easily when the time comes.
 
Maki Jav
Ranch Hand
Posts: 445
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I agree with William Brogden. You may store your data to a Vector in your Servlet and at appropriate time save that Vector (persist data) periodically.

I can help you further if your want!

Maki Java
[ September 25, 2007: Message edited by: Maki Jav ]
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic