This week's book giveaway is in the Jython/Python forum.
We're giving away four copies of Hands On Software Engineering with Python and have Brian Allbey on-line!
See this thread for details.
Win a copy of Hands On Software Engineering with Python this week in the Jython/Python 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:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Bear Bibeault
  • Knute Snortum
  • Liutauras Vilda
Sheriffs:
  • Tim Cooke
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Tim Moores
  • Frits Walraven
  • Ron McLeod
  • Ganesh Patekar
  • salvin francis
Bartenders:
  • Tim Holloway
  • Carey Brown
  • Stephan van Hulst

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.
 
Marshal
Posts: 67192
169
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: 20099
101
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.
 
Won't you be my neighbor? - Fred Rogers. tiny ad:
RavenDB is an Open Source NoSQL Database that’s fully transactional (ACID) across your database
https://coderanch.com/t/704633/RavenDB-Open-Source-NoSQL-Database
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!