I am writing a simple web service on java, that should read an xml file and generate a string for result. I am, however, at loss as to:
a) where should xml file be placed in the file system for it to be accessible to web service?
b) what would the relative way to the file from the service
c) alternatelyt, how can i add xml file to the project, so that it would be deployed along with web service
I am using NetBeans as IDE and maven as a build system.
Usually I provide a resource-bundle (.jar) in my web application. If the file should not be modified during runtime, this should be the best way to access it. This will be c) in your question. There you can access the file with:
"resourceName"will be the path inside the jar file. I you are packaging with Maven, everything insrc/main/webapp/WEB-INF/classeswill be available in your classpath and can be loaded withgetResourceAsStream.An alternative way with maven is to create a new module and place all required resources in
src/main/resourcesand then add a dependency to this artifact in your webapp pom.