• 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

Getting path inside Tomcat.

 
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is a question of implementation and best practices. I instantiate Class A inside my servlet, which in turn instantiates Class B. The problem is that Class B needs to load xslt stylesheets from WEB-INF/xslt. What is the best way for Class B to know where to load the sheets from? Right now I'm using context.getRealPath("/") within the servlet and then passing the path into Class A and subsequently Class B. Is there a better way to do this? Should I pass the context around instead?
I don't have this problem with my properties files, which are in the classes directory, where I can use getClass().getResourceAsStream("fileName"). I don't think this works outside the classes directory, however.
Thanks in advance.
 
Wes Hughes
Ranch Hand
Posts: 31
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Whoops...just noticed that this should probably be in Servlets. You can move if neccessary.
 
Something about .... going for a swim. With this tiny ad ...
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic