• 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
  • Liutauras Vilda
  • Bear Bibeault
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Junilu Lacar
  • Paul Clapham
  • Knute Snortum
Saloon Keepers:
  • Stephan van Hulst
  • Ron McLeod
  • Tim Moores
  • salvin francis
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Frits Walraven
  • 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.
 
Marshal
Posts: 67254
170
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: 20562
120
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.
 
I'm a lumberjack and I'm okay, I sleep all night and work all day. Lumberjack ad:
global solutions you can do in your home or backyard
https://coderanch.com/t/708587/global-solutions-home-backyard
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!