Reading/writing a text file in a servlet, where should this file be stored in JBoss?

前端 未结 1 1076
抹茶落季
抹茶落季 2020-12-06 03:56

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?<

相关标签:
1条回答
  • 2020-12-06 04:01

    There the /data directory is for.

    enter image description here


    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");
    // ...
    

    See also:

    • JBoss Wiki - JBoss Properties

    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).

    0 讨论(0)
提交回复
热议问题