在servlet中读取/写入文本文件,该文件应存储在JBoss中的什么位置? [英] Reading/writing a text file in a servlet, where should this file be stored in JBoss?
本文介绍了在servlet中读取/写入文本文件,该文件应存储在JBoss中的什么位置?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我在JBoss中部署了servlet.我想根据客户端输入将数据读/写到文本文件中.该文本文件应放在JBoss目录结构的何处?
I have servlet deployed in JBoss. I want to read/write data into a text file based on the client input. Where should this text file be put in the JBoss directory structure?
推荐答案
/data
目录用于此目录.
其绝对路径可由jboss.server.data.dir
系统属性提供.
Its absolute path is available by the jboss.server.data.dir
system property.
File dataDir = new File(System.getProperty("jboss.server.data.dir"));
File yourFile = new File(dataDir, "filename.ext");
// ...
另请参见:
- JBoss Wiki-JBoss属性
- JBoss Wiki - JBoss Properties
See also:
请注意,您是通过这种方式将Web应用程序代码紧密耦合到特定服务器.如果要更改服务器,请记住将上述代码也更改为新服务器支持的(或不支持).
Note that you're this way tight-coupling the web application code to a specific server. If you ever want to change servers, keep in mind to change the above code as well to whatever the new server supports (or not).
这篇关于在servlet中读取/写入文本文件,该文件应存储在JBoss中的什么位置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文