write a file to a specified directory
2 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Bart_Mas
Posted On:   Thursday, May 8, 2003 01:48 AM

I have an application in Tomcat. In this application i write data into an xml-file. When i check this, i see that the file is written in the bin directory of tomcat. Now I want to write this file into another directory, for example:
/tomcat/webbaps/catalog/orders/order.xml

Can someone tell me how my code to place it in this specified directory looks like?



Thx !

Re: write a file to a specified directory

Posted By:   Alexei_Tarkhov  
Posted On:   Thursday, May 8, 2003 08:03 AM

Another possible solution, would be, to add to web.xml a (global) context parameter, pointing to a path location where you'd like to put your files, e.g. /tmp. After that, all your servlets can easily get this path to write their files to.
Regards,

Re: write a file to a specified directory

Posted By:   AlessandroA_Garbagnati  
Posted On:   Thursday, May 8, 2003 03:06 AM

Bart,

If you want to save that file anywhere under the root directory of your context, just take a look at the getRealPath() method of the javax.servlet.ServletContext interface. The javadoc will give you all the information you need.
About | Sitemap | Contact