I have to use a xml file from file system, for example, a file with the name of treeview.xml, located in the WEB-INF/classes/com/yahoo/resources/, and I need to use that in a class of web layer. how cannot I get the path of that file? later, I was wondering if I can write the path into the web.xml as a parameter. but how to use it in a class? poor knowledge about this. pls help me. any word is apprieciable.
Thank you for your reply, but how about when my class is not a servlet? in fact, i'm making a delegate to get data from ejb, then use a xml file to transform the data into something satisfy the client. If the class is not a servlet, which means I cannot use servletConfig, so what can I do to get the path from web layer name space? thank you again, and waiting for your reply.
Take a look at the ServletContext API. You will find the methods such as getRealPath and getResourcePaths that you can use to get the real path to a file from the web-application relative path. Get the path in your init() method and keep it around as an instance variable to be passed to your helper class. Bill
What's a year in metric? Do you know this metric stuff tiny ad?
Gift giving made easy with the permaculture playing cards