• 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

Location of configuration file

 
Ranch Hand
Posts: 70
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I created dynamic web project in RAD.

I have a java class called jmssender.java

in this file i have to refer my configuration file named config.xml .

where should i place this config.xml in my project.

I have placed in webcontent/WEB-INF/config.xml

but my java class not taking this xml file.

Tell me the location for my configuration file in my project


Thanks
Kavitha
 
Saloon Keeper
Posts: 27762
196
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This doesn't sound like an Ant or Maven question, although if you're using Maven, there's a Maven-specific answer.

As far as accessing the file goes, it depends on how you intend to use the file. A webapp shouldn't be viewed as a directory subtree. Yes, when you construct it, you might lay out the components in a directory subtree, and URLs may LOOK like filesystem paths. But they're not.

You have 2 choices.

1. Put the config file OUTSIDE of the WEB-INF directory and open it via a URL reference, the same way you would to get an image, javascript or css file.

2. Put it inside WEB-INF/classes or in a jar inside the WEB-INFO/libs directory. That will place the file in your classpath. Then use the getResourceAsStream servlet context method to read it.

If you don't want people to be able to pull up copies of the config file through their web browsers, use choice #2.
 
reply
    Bookmark Topic Watch Topic
  • New Topic