aspose file tools*
The moose likes JSP and the fly likes reading/writing to a file from JSP Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSP
Bookmark "reading/writing to a file from JSP" Watch "reading/writing to a file from JSP" New topic
Author

reading/writing to a file from JSP

Sam Tilley
Ranch Hand

Joined: Dec 05, 2001
Posts: 160
Hi,
I need to create a JSP page that contains 200 checkboxes each worth an amount of money. The idea is that someone will buy a checkbox providing sponsorship for a charity event(they are buying the number of lengths swum in a pool). My task is to create a table of checkboxes which is the easy part, but then i need to grey over the check box once someone has used it, so need to write this to something so that every time someone opens it up it shows which ones have been taken.
The one thing is that i may not have a database to write the info to so have been trying to write it to a text file instead, however i have been having some problems getting the data out of the file and into my JSP using
Is this the best idea to do this or is there another way to store info for a webapplication that is failsafe.
Thanks


Sam Tilley SCJP, SCWCD
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12823
    
    5
Reading and writing in the same file is likely to be a disaster.
You should create an object that holds all of the data representing the checkboxes. Keep it in memory and write it out every time it gets changed.
Bill
Harry D'Souza
Greenhorn

Joined: Dec 28, 2002
Posts: 28
I am not a PRO with JSP but this would be my first guess too -- I would want to write to a text file . But instead of having a BufferedReader and a BufferedWriter refering to the same file I would rather use RandomAccessFile which implements the standard input and the output methods.
-Harry.


Harry D'Souza<br />SJCP 1.4 , SCWCD
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: reading/writing to a file from JSP