Hi, i have two text files (abcd.txt and efgh.txt). text file abcd.txt contains names of districts in a country with their area values whereas the file efgh.txt contains the names of the same districts but with their population values. (the text files have only two columns: name of the district and either the area/population values) now i want to write a servlet that extracts the 'area' values from abcd.txt and 'population' values from efgh.txt and calculates Density ie divides the area values by the population values and obtain the result. since i am new to Servlets, i am in desperate need of some sort of sample code in proceeding with the above functionality. thanks in advance.
A good way to procedd is as follows. To load a file called 'conversion.dat' for the sake of argument, with a path of WEB-INF/currency relative to your application root, put the following in your web.xml (for tomcat at least!) file straight after your opening <webapp> label:
Now from within your servlet, create a File instance using this path:
Note the getServletContext() method must be called from within a servlet.
You can then treat this file in the normal way.
Jon [ May 25, 2004: Message edited by: Jon Entwistle ]