Where to write a file in Tomcat 8 and Servlet /JSP on my Hard Disk ?
Posted by: Harish Pal
Date: September 29, 2015 04:37AM

Hi all,
I want to write my.properties file. My query is that “In which path it should be created”. I have installed glassfish on my Linux 14.04 machine on this path: /opt/glassfish4 and created the file my.properties at: /opt/glassfish4/glassfish/domains/swManzana/config/my.properties
This is my Java Code:

Boolean wflag = false;
String wnomfile="my.properties"
Properties prop = new Properties();
OutputStream output = null;
System.out.println("Inicio Archivo Properties.. " + wnomfile);
try {
// output = new FileOutputStream("config.properties");
output = new FileOutputStream(wnomfile);
System.out.println("Archivo Creado Properties..");
// set the properties value
prop.setProperty("database", "localhost");
// save properties to project root folder
System.out.println("Archivo Creado/Grabado Properties..");
System.out.println("Error Archivo Properties Exception..");
System.out.println("Archivo Properties inicio Finally..");
System.out.println("Archivo Properties Antes de CLOSE Finally..");
System.out.println("Archivo Properties Grabado Finally..");
System.out.println("Archivo Properties Exception-Finally..");
return wflag;

While executing the above code my.properties file not created. Why Tomcat is not creating this file. I have properly checked my tomcat installation and found no issues in access web Pages and ports.
Can anyone suggest me some knowledgeable tutorials URL Links on Java questions and answers forum, so that I can get my query resolved faster.

Options: ReplyQuote

Written By
Where to write a file in Tomcat 8 and Servlet /JSP on my Hard Disk ?
September 29, 2015 04:37AM

Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.