public void checkOutputDir() {
   if (outputDir != null) {
     if (!(new File(outputDir)).exists()) {
       makeOutputDir();
     }
   } else {
     createOutputDir();
   }
 }
Example #2
0
  /**
   * Compile the jsp file from the current engine context. As an side- effect, tag files that are
   * referenced by this page are also compiled.
   *
   * @param compileClass If true, generate both .java and .class file If false, generate only .java
   *     file
   */
  public void compile(boolean compileClass)
      throws FileNotFoundException, JasperException, Exception {

    try {
      // Create the output directory for the generated files
      // Always try and create the directory tree, in case the generated
      // directories were deleted after the server was started.
      ctxt.makeOutputDir(ctxt.getOutputDir());

      // If errDispatcher is nulled from a previous compilation of the
      // same page, instantiate one here.
      if (errDispatcher == null) {
        errDispatcher = new ErrorDispatcher(jspcMode);
      }
      generateJava();
      if (compileClass) {
        generateClass();
      } else {
        // If called from jspc to only compile to .java files,
        // make sure that .java files are written to disk.
        javaCompiler.doJavaFile(ctxt.keepGenerated());
      }
    } finally {
      if (tfp != null) {
        tfp.removeProtoTypeFiles(null);
      }
      // Make sure these object which are only used during the
      // generation and compilation of the JSP page get
      // dereferenced so that they can be GC'd and reduce the
      // memory footprint.
      tfp = null;
      errDispatcher = null;
      if (!jspcMode) {
        pageInfo = null;
      }
      pageNodes = null;
      if (ctxt.getWriter() != null) {
        ctxt.getWriter().close();
        ctxt.setWriter(null);
      }
    }
  }