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.....
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.
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.
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.
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.