• 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

Tomcat server root path

 
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,
How do I find out a path of server root from servlet, or current location of the running servlet? Thanks.

John
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by John McDonald:

How do I find out a path of server root from servlet



servletContext.getRealPath( "/" );

Only works when the app is not being run out of an unexpanded war file.

Originally posted by John McDonald:

or current location of the running servlet?



I don't know what that means. The location of the class file? Other than that (which is not useful info generally), servlets don't really have the concept of a "location".
[ March 20, 2006: Message edited by: Bear Bibeault ]
 
John McDonald
Ranch Hand
Posts: 112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I got an exception when I tried to use this. It is access denial. Other approach? Thanks.
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Then you have an issue with your setup. Trying "another approach" because the supported method isn't working due to a setup problem isn't the best course of action.
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Or, are you running the app out of an unexpanded war file?

If not, you're probably having a file system permissions issue that will need to be resolved.
 
John McDonald
Ranch Hand
Posts: 112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks for all the input. Yes, I tried to dynamically generate a some html file at the root of my war file. Say


Tomcat\bin
\conf
\webapps\generator.war
generator\WEB-INF\classes\package\servlet.class


I need to generate a html file so that I can access throught the browser as
http://mydomain/generator/html/new_html.html file.

How do I acquire the physical path from the servlet so that I can gernate such html file? Thanks.
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I already told you how to do it. If you are having a permissions problem with the file system that is something you are going to have to straighten out with the system admin for the server.
 
reply
    Bookmark Topic Watch Topic
  • New Topic