simply replace new File("temp.txt") with...


new File(context.getRealPath("temp.txt"))

However, note that this may return null in the case that the webapp is being served directly from a .war file and not from a directory. A better strategy is loading the resource as an InputStream...

context.getResourceAsStream("temp.txt")

You can wrap that in an InputStreamReader and none of the rest of your code will change and it will always work as long as temp.txt is located in the root of your webapp whether it is in a directory or a .war file.

Jake

At 11:44 AM 11/6/2003 +0000, you wrote:
Hi all, try { BufferedReader br = new BufferedReader(new FileReader(new File("temp.txt").getAbsolutePath())); String temp; while((temp = br.readLine()) != null) { out.println(temp); } } catch(Exception e) {out.println("<h1>ERROR....</h1>" + e.toString());} the br field now has a file using this path c:\winnt\system32\test.txt? The txt file and .jsp file are in C:\Program Files\Apache Group\Tomcat 4.0\webapps\ROOT\testing How can I tell the jsp (or tomcat) to look in the same directory before trying what I assume is the PATH environment variable? thanks for all your help peeps. Chris. NOTE: The information in this email is confidential. If you are not the intended recipient, you must not read, use or disseminate this information. Although this email and any attachments are believed to be free of any virus, or any other defect which affect any computer or IT system into which they are received and opened, it is the responsibility of the recipient to ensure that they are virus free and no responsibility is accepted by London City Airport for any loss or damage rising in any way from receipt or use thereof. The contents of this message including any attachments does not necessarily reflect the view of London City Airport, unless expressly stated to the contrary the message is the work of a sender acting as an individual. www.londoncityairport.com ____________________________________________________________ This e-mail has been scanned for viruses by MCI's Internet Managed Scanning Services - powered by MessageLabs. For further information visit http://www.mci.com


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to