aspose file tools*
The moose likes JSP and the fly likes calculations using JSP Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "calculations using JSP" Watch "calculations using JSP" New topic
Author

calculations using JSP

Yell Srik
Ranch Hand

Joined: Mar 10, 2004
Posts: 61
hi,
i am new to JSP and need ur help in doing the following.
i have a text file that contains three columns: name, salary, tax with 10 rows of data.
eg: name salary tax
aa 1000 100
bb 2000 200
............
using JSP/Servlets, how is it possible to extract data values from salary and tax columns and perform calculation like (salary-tax),(salary+tax) etc.
thanks in advance.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 61756
    
  67

What have you tried? What has you stumped?


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Nadeem Ahmad
Greenhorn

Joined: Oct 20, 2003
Posts: 28
Hi,
You read the file by using
File f = new File("c:\\io\\data.txt");
RandomAccessFile rf = new RandomAccessFile(f,"rw");
rf.readLine())
and then split the line with Space or any other delimeter (which is being used in the text file)
using StringTokenizer
Here is the example..
| is the delimeter incase of ur file it is space
String username=null;
try{
File f = new File("c:\\io\\data.txt");
RandomAccessFile rf = new RandomAccessFile(f,"rw");
while((username=rf.readLine())!=null){
i=0;
StringTokenizer st = new StringTokenizer(username,"|");
String pr="";
while (st.hasMoreTokens()) {
entry[i]=st.nextToken();
i++;
}
}

}
rf.close();
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: calculations using JSP