Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Filename with environment variable?

Status
Not open for further replies.

shine67

Programmer
Jan 11, 2002
41
0
0
US
Hi,

I am writing a jsp running under Apache/Tomcat in which I try to do some file I/O's:

FileWriter afile = new FileWriter("/a/n/c/d/e/output.txt");

Is there anyway to define and use some kind of environment variable under with Apache or Tomcat or even under unix such as:

FileWriter afile = new FileWriter("SOME_PATH/e/output.txt");

Right now I write the whole path wherever I need to open a file and it is really cumbersome and I am sure there is a better way of doing this.

Thanks,
Shine
 
Hi,

This may not be the solution that you are looking for. If you are opening lots of files in the same JSP page couldnt you just use a string constant:
<%!
public static final String MY_PATH = &quot;a/b/c/d/&quot;;
%>
This obviously wont work if you want to use in on a number ofpages.
How about looking in web.xml and seeing if you can use the init param tag? I am not entirely sur how this works but i think it might work.

Hope that helps
Al.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top