Server path of a file
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Moris_Ravasio
Posted On:   Monday, October 25, 2004 02:00 AM

Hi all. I'm a JSP beginner and I'm trying to set up my first application dealing with databases. I'm using Tomcat 5.0.28. I established a DSN-less connection with a MS Access database, but I have to hard-code in the application the full path to the Access file (C:/ProgramFiles/Tomcat/webapps/ROOT/mysite/data.mdb)... Is there a way to map the application directory on the server directory? I mean: is there something similar to ASP's Server.MapPath()? In other words: I would like to write in my application something like: String dbFile = SomeFunction("data.mdb") where "data.mdb" is in the same folder of the JSP page in which this code is written, and SomeFunction is some function that returns the server full p   More>>

Hi all. I'm a JSP beginner and I'm trying to set up my first application dealing with databases. I'm using Tomcat 5.0.28. I established a DSN-less connection with a MS Access database, but I have to hard-code in the application the full path to the Access file (C:/ProgramFiles/Tomcat/webapps/ROOT/mysite/data.mdb)... Is there a way to map the application directory on the server directory? I mean: is there something similar to ASP's Server.MapPath()?

In other words: I would like to write in my application something like:

String dbFile = SomeFunction("data.mdb")

where "data.mdb" is in the same folder of the JSP page in which this code is written, and SomeFunction is some function that returns the server full path to data.mdb.

Maybe my question is stupid and there are other ways to do that...

Thanks for your answers.

Regards.

   <<Less

Re: Server path of a file

Posted By:   Anonymous  
Posted On:   Tuesday, October 26, 2004 10:44 AM

real_path = Context().getRealPath( virtual_path )

try something like :
String real_path =Context().getRealPath("/ROOT/mysite/data.mdb");

in jsp I think :
application.getRealPath("/ROOT/mysite/data.mdb");

About | Sitemap | Contact