This week's book giveaway is in the General Computing forum.
We're giving away four copies of Learning Regular Expressions and have Ben Forta on-line!
See this thread for details.
Win a copy of Learning Regular Expressions this week in the General Computing forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

how to get absolute path of linked resource outside of Tomcat  RSS feed

 
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm trying to get the absolute path from a relative path. The problem is that the file I'm trying to access is not under the /Tomcat/ directory. Currently I can link to the file using a relative path, but I need to use the File object to iterate through the files in the directory.

For clarification, I'm running cruisecontrol on Tomcat 5.5. The JSP files are in D:\Tomcat\webapps\cruisecontrol. However, the log files are in C:\logs. Because of the way cruisecontrol is configured I can link to the "C:\logs\project\cruisecontrol.log" using the relative path 'href="<%= artifacts_url %>/cruisecontrol.log', where artifacts_url="/logs/project/". I've tried to read that as a File object to then getAbsolutePath(), but haven't had any luck yet.

Is what I'm trying to do possible? Please let me know if I can be more clear in the asking of this question.

TIA, John
 
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're probably looking for getRealPath
[ July 31, 2007: Message edited by: Ben Souther ]
 
John Dunning
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the reply; unfortunately, that still gives me the path to the Tomcat installation directory plus the filename, even though that file is not there.
 
Author and ninkuma
Marshal
Posts: 66806
168
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As your file is outside the purview of the web app, there is no way to automatically determine its path. You'll need to provide it. Rather than hard-coding it, consider using a context parameter or even a properties file.
 
Bartender
Posts: 19735
92
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
To amplify on Bear's statement: A URL is not the same thing as a file path. They may look like file paths. They are often mapped to file paths. But they're not the same thing as file paths. A web server is not the same thing as a file server.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!