Hi i must create a XML file in the project using java dynamically and must read it using the base Path URL. i can read the File when i create it manually, but not able to create it dynamically. When i use File f1 = new File(“test.XML”); it create the file in the tomcat’s Bin folder. The file must be created in the Project while Running in both Tomcat and Jboss EAP 6.
Share
You can get the real path of the web application using the servlet context:
Note: if you’re running tomcat/jboss on Linux, you’ll probably have to give permission to write in the webapp folder though, which is most likely forbidden by default.
Quoting from Servlet API docs of
ServletContext.getRealPath():