• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

ServletContect and getRealPath() from a WAR file

 
Ranch Hand
Posts: 223
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi all,
I use getServletContext().getRealPath(sConfig); to get the real path of a file with my Tomcat structure. This works fine in a straight Tomcat environment. However, If I build a WAR file and deploy it, it doesn't work, no surprise, since it says so in the Sun API-Javadoc. But what do I do so that I can optain the real path if I deploy my web application in a WAR file?
TIA, Detlef
 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm not sure I understand your question, but I've had the same problems when using Jar files for my applications. Do not forget the leading / for searching your file relating to your web app context.
Hope it helps,
St�phane
 
Sheriff
Posts: 7001
6
Eclipse IDE Python C++ Debian Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
It's strongly recommended that you don't use "getRealPath" in your web applications. Sure Tomcat expands wars out to real files, but there are several servers which run your application straight from a war file.
All servers should provide a temporary working directory to each web application, to use when you need to store things (uploaded files, temporary configs etc.), and you should load other files using getResource()
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic