• 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

file path in web container

 
Ranch Hand
Posts: 112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi there, I would like to deposit a dynamic generated page for subsequent calls. But I don't know how to set a path for it. As you know, that the general path for web container as follow:
..\tomcat5512\webapps\ROOT\html

If my servlet generates a.html, b.html under above directory, how do I set the path relative to that directory?

I don't want to has java code to pick up by environment variable. and my servlet package is a.b.c because I want to turn this servlet to bean in phrase 2. Thank you very much.

John
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
John,
One thing to keep in mind.
Java webapps aren't always deployed as a file system directory.
When they are, you can get the system path to any resource within your application using ServletContext.getRealPath

If your webapp is deployed as a packed war file this method will return null.

A more robust way of doing this is to use context init params or servlet init params that are configured in web.xml.
reply
    Bookmark Topic Watch Topic
  • New Topic