Example #1
0
 public String replace(ReplacerContext ctx, Map<String, String> attr, boolean isClosed) {
   String uri = attr.get("uri");
   String prefix = attr.get("prefix");
   PageContext pageContext = processor.getPageContext();
   TagLibraryInfo tli = createTagLibraryInfo(pageContext, prefix, uri);
   for (TagInfo ti : tli.getTags()) {
     if (ti.getTagClassName() == null) {
       continue;
     }
     processor.addTagLib(prefix, ti);
   }
   processor.addPrefixCheck(prefix);
   return "";
 }
 public String getFQCN() {
   String name;
   if (isTagFile()) {
     name = tagInfo.getTagClassName();
   } else {
     name = getServletPackageName() + "." + getServletClassName();
   }
   return name;
 }
  /** Path of the Java file relative to the work directory. */
  public String getJavaPath() {

    if (javaPath != null) {
      return javaPath;
    }

    if (isTagFile()) {
      String tagName = tagInfo.getTagClassName();
      javaPath = tagName.replace('.', '/') + ".java";
    } else {
      javaPath = getServletPackageName().replace('.', '/') + '/' + getServletClassName() + ".java";
    }
    return javaPath;
  }
 /**
  * Package name for the generated class is make up of the base package name, which is user
  * settable, and the derived package name. The derived package name directly mirrors the file
  * hierarchy of the JSP page.
  */
 public String getServletPackageName() {
   if (isTagFile()) {
     String className = tagInfo.getTagClassName();
     int lastIndex = className.lastIndexOf('.');
     String pkgName = "";
     if (lastIndex != -1) {
       pkgName = className.substring(0, lastIndex);
     }
     return pkgName;
   } else {
     String dPackageName = getDerivedPackageName();
     if (dPackageName.length() == 0) {
       return basePackageName;
     }
     return basePackageName + '.' + getDerivedPackageName();
   }
 }
  /** Just the class name (does not include package name) of the generated class. */
  public String getServletClassName() {

    if (className != null) {
      return className;
    }

    if (isTagFile) {
      className = tagInfo.getTagClassName();
      int lastIndex = className.lastIndexOf('.');
      if (lastIndex != -1) {
        className = className.substring(lastIndex + 1);
      }
    } else {
      int iSep = jspUri.lastIndexOf('/') + 1;
      className = JspUtil.makeJavaIdentifier(jspUri.substring(iSep));
    }
    return className;
  }
  public Class load() throws JasperException, FileNotFoundException {
    try {
      getJspLoader();

      String name;
      if (isTagFile()) {
        name = tagInfo.getTagClassName();
      } else {
        name = getServletPackageName() + "." + getServletClassName();
      }
      servletClass = jspLoader.loadClass(name);
    } catch (ClassNotFoundException cex) {
      throw new JasperException(Localizer.getMessage("jsp.error.unable.load"), cex);
    } catch (Exception ex) {
      throw new JasperException(Localizer.getMessage("jsp.error.unable.compile"), ex);
    }
    removed = 0;
    return servletClass;
  }
  protected void createOutputDir() {
    String path = null;
    if (isTagFile()) {
      String tagName = tagInfo.getTagClassName();
      path = tagName.replace('.', File.separatorChar);
      path = path.substring(0, path.lastIndexOf(File.separatorChar));
    } else {
      path = getServletPackageName().replace('.', File.separatorChar);
    }

    // Append servlet or tag handler path to scratch dir
    try {
      File base = options.getScratchDir();
      baseUrl = base.toURI().toURL();
      outputDir = base.getAbsolutePath() + File.separator + path + File.separator;
      if (!makeOutputDir()) {
        throw new IllegalStateException(Localizer.getMessage("jsp.error.outputfolder"));
      }
    } catch (MalformedURLException e) {
      throw new IllegalStateException(Localizer.getMessage("jsp.error.outputfolder"), e);
    }
  }