Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

servlets

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?

like image 555
Ashwin Avatar asked Jan 18 '23 09:01

Ashwin


1 Answers

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

like image 135
BalusC Avatar answered Jan 19 '23 22:01

BalusC