File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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
JavaRanch » Java Forums » Java » JSP
Bookmark "calculations using JSP" Watch "calculations using JSP" New topic

calculations using JSP

Yell Srik
Ranch Hand

Joined: Mar 10, 2004
Posts: 61
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

Joined: Jan 10, 2002
Posts: 63865

What have you tried? What has you stumped?

[Asking smart questions] [About Bear] [Books by Bear]
Nadeem Ahmad

Joined: Oct 20, 2003
Posts: 28
You read the file by using
File f = new File("c:\\io\\data.txt");
RandomAccessFile rf = new RandomAccessFile(f,"rw");
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;
File f = new File("c:\\io\\data.txt");
RandomAccessFile rf = new RandomAccessFile(f,"rw");
StringTokenizer st = new StringTokenizer(username,"|");
String pr="";
while (st.hasMoreTokens()) {

subject: calculations using JSP
It's not a secret anymore!