i've created a webapp that i deploy on the debian default tomcat9 server.
I need to write PDF files to the local filesystem. So i create a folder and write them using the ByteArrayOutputStream and a FileOutputStream.
The webapp is deployed by copying the war file to the /var/lib/tomcat9/webapps directory.
I want the files to be created in the following Path: /home/myuser/rechnungsexport/a1/
when i run the code, the tomcat server creates them in the following path:
/tmp/systemd-private-6ce0d50d8582493fb365de9c539261d0-tomcat9.service-bsQJTg/home/myuser/rechnungsexport/a1/
This is the Java code that writes the File
String lokalerDateiPfad = "/home/myuser/rechnungsexport/a1/";
ByteArrayOutputStream baos = new ByteArrayOutputStream();
JasperExportManager.exportReportToPdfStream(jasperPrint, baos);
try (OutputStream outputStream = new FileOutputStream(lokalerDateiPfad + dateiName)) {
baos.writeTo(outputStream);
} catch (Exception e) {
logger.error(e);
}
How can i change this so that my application creates them in the correct directory ?