This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
My java web app needs to parse in, an xml file. The app is on a web host server (not on my localhost), so I cannot do it like 'c:/xxxxx.xml'. Where can I put this file in my server, so that I can parse it in? And also, in which folder?
I have tried putting it in various folders of the web app but it is still not being seen by the pojo class trying to read it.
It would be better to use getResourceAsStream() because getRealPath() can not be used when the file is inside a jar file.However,getResourceAsStream() or getResource().openStream() can be used even for files inside a jar file.
Joined: Feb 26, 2005
The parse("") still cannot find the file, when I used the ResourceAsStream.
I put the input file, in the same level as WEB-INF, outside the WEB-INF.
Is this file served properly? It is quiet possible you have misspelt the file name.
Got "The page cannot be found".
Joined: Oct 26, 2006
I hope you have replaced <portnum> with a valid number as 8080 if you are using tomcat and <appname> with you own webapplication name. Assuming you have done that,the message shows that the file is not present in you app and thats why the resource is not found. Check the name of the file again, see if you have misspelt it.