// Try to open a file and write to it.
String catalinaHome = "/usr/local/jakarta-tomcat-4.1.24";
File testFile = new File(catalinaHome + "/webapps/ROOT", "test.txt");
FileOutputStream fileOutputStream = new FileOutputStream(testFile);
fileOutputStream.write(new String("testing...").getBytes());
fileOutputStream.close();
// If we get down this far, the file was created successfully.
PrintWriter out = response.getWriter();
out.println("File created successfully!");