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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

File IO in Tomcat

Status
Not open for further replies.

tommyc7

Programmer
Feb 3, 2007
33
US
Can anyone recommend a good tutorial or reference guide on how to do File I/O in a Tomcat web server?

Specifically, I am using Tomcat 4. For some reason, I can't seem to grasp the basics of how Tomcat determines what the base directory is.

For example:

If I put this line of code in a JSP page:

Code:
<a href="/">I point to the root folder.</a>

I will bring me to:

Code:
[URL unfurl="true"]http://localhost:8080/[/URL]

This seems odd to me, because it seems like the base directory should be in the web application and not the entire web server.

However, in my actually Java code, if I use "/" for the directory it writes to my "C:\". If I use ".", it writes to the $CATALINA_HOME\bin directory.

According to Sun's site, there's no guaranteed way to read environment variables in Java objects, so I don't know how to tell my Java clases to start at $CATALINA_HOME except to make my base "..". And will this even remain consistent when I deploy on my ISP? Can I get this information through some class in the servlet?

As you can see, I'm confused. Is there a good reference for File I/O in Tomcat?

Thanks!

Tom
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top