• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

storing data without using a database.

 
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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...
 
Bartender
Posts: 1638
IntelliJ IDE MySQL Database Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 MySQL Database Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 2308
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Its depends on the what kind of data you storing....
 
Sheriff
Posts: 3341
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 473
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
Are you okay? You look a little big. Maybe this tiny ad will help:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic