jsp页面创建文件后没有生成对应的文件

jsp页面的一段测试代码

    String content = "12345上山打老虎";
    File file = new File("123.txt");
    try {
        file.createNewFile();
    }catch (IOException e){
        e.printStackTrace();
    }
    try {
        PrintWriter pw = new PrintWriter(new FileOutputStream(file));
        pw.println(content);
        pw.close();
    }catch (IOException e){
        e.printStackTrace();
    }

没有报错也没有抛出异常,但是目录下没有123.txt
小白一名,不是很懂,请多指教!

tomcat logs 目录的 catalina.log ,会打印详细错误信息。

建议:项目中别使用 e.printStackTrace(); 打印日志(控制台输出),而应该使用 logger.error("", e); 打印。