当前位置: 首页>>代码示例>>Java>>正文


Java JspCompilationContext.getServletJavaFileName方法代码示例

本文整理汇总了Java中org.apache.jasper.JspCompilationContext.getServletJavaFileName方法的典型用法代码示例。如果您正苦于以下问题:Java JspCompilationContext.getServletJavaFileName方法的具体用法?Java JspCompilationContext.getServletJavaFileName怎么用?Java JspCompilationContext.getServletJavaFileName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.jasper.JspCompilationContext的用法示例。


在下文中一共展示了JspCompilationContext.getServletJavaFileName方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getServletFileNameForJsp

import org.apache.jasper.JspCompilationContext; //导入方法依赖的package包/类
@Override
public String getServletFileNameForJsp(Context context, String jspName) {
  String servletName = null;

  ServletConfig servletConfig = (ServletConfig) context.findChild("jsp");
  if (servletConfig != null) {
    ServletContext sctx = context.getServletContext();
    Options opt = new EmbeddedServletOptions(servletConfig, sctx);
    JspRuntimeContext jrctx = new JspRuntimeContext(sctx, opt);
    JspCompilationContext jcctx = createJspCompilationContext(jspName, opt, sctx, jrctx, null);
    servletName = jcctx.getServletJavaFileName();
  } else {
    logger.error(NO_JSP_SERVLET, context.getName());
  }
  return servletName;
}
 
开发者ID:psi-probe,项目名称:psi-probe,代码行数:17,代码来源:AbstractTomcatContainer.java

示例2: getServletFileNameForJsp

import org.apache.jasper.JspCompilationContext; //导入方法依赖的package包/类
public String getServletFileNameForJsp(Context context, String jspName) {
    String servletName = null;

    ServletConfig servletConfig = (ServletConfig) context.findChild("jsp");
    if (servletConfig != null) {
        ServletContext sctx = context.getServletContext();
        Options opt = new EmbeddedServletOptions(servletConfig, sctx);
        JspRuntimeContext jrctx = new JspRuntimeContext(sctx, opt);
        JspCompilationContext jcctx = createJspCompilationContext(jspName, false, opt, sctx, jrctx, null);
        servletName = jcctx.getServletJavaFileName();
    } else {
        logger.error("Context " + context.getName() + " does not have \"jsp\" servlet");
    }
    return servletName;
}
 
开发者ID:andresol,项目名称:psi-probe-plus,代码行数:16,代码来源:AbstractTomcatContainer.java

示例3: JavacErrorDetail

import org.apache.jasper.JspCompilationContext; //导入方法依赖的package包/类
/**
 * Constructor.
 *
 * @param javaFileName The name of the Java file in which the
 * compilation error occurred
 * @param javaLineNum The compilation error line number
 * @param jspFileName The name of the JSP file from which the Java source
 * file was generated
 * @param jspBeginLineNum The start line number of the JSP element
 * responsible for the compilation error
 * @param errMsg The compilation error message
 * @param ctxt The compilation context
 */
public JavacErrorDetail(String javaFileName,
        int javaLineNum,
        String jspFileName,
        int jspBeginLineNum,
        StringBuilder errMsg,
        JspCompilationContext ctxt) {

    this.javaFileName = javaFileName;
    this.javaLineNum = javaLineNum;
    this.errMsg = errMsg;
    this.jspFileName = jspFileName;
    // Note: this.jspBeginLineNum is set at the end of this method as it may
    //       be modified (corrected) during the execution of this method

    if (jspBeginLineNum > 0 && ctxt != null) {
        try (InputStream is = ctxt.getResourceAsStream(jspFileName)) {
            // Read both files in, so we can inspect them
            String[] jspLines = readFile(is);

            try (FileInputStream fis = new FileInputStream(ctxt.getServletJavaFileName())) {
                String[] javaLines = readFile(fis);

                if (jspLines.length < jspBeginLineNum) {
                    // Avoid ArrayIndexOutOfBoundsException
                    // Probably bug 48498 but could be some other cause
                    jspExtract = Localizer.getMessage("jsp.error.bug48498");
                    return;
                }

                // If the line contains the opening of a multi-line scriptlet
                // block, then the JSP line number we got back is probably
                // faulty.  Scan forward to match the java line...
                if (jspLines[jspBeginLineNum-1].lastIndexOf("<%") >
                    jspLines[jspBeginLineNum-1].lastIndexOf("%>")) {
                    String javaLine = javaLines[javaLineNum-1].trim();

                    for (int i=jspBeginLineNum-1; i<jspLines.length; i++) {
                        if (jspLines[i].indexOf(javaLine) != -1) {
                            // Update jsp line number
                            jspBeginLineNum = i+1;
                            break;
                        }
                    }
                }

                // copy out a fragment of JSP to display to the user
                StringBuilder fragment = new StringBuilder(1024);
                int startIndex = Math.max(0, jspBeginLineNum-1-3);
                int endIndex = Math.min(
                        jspLines.length-1, jspBeginLineNum-1+3);

                for (int i=startIndex;i<=endIndex; ++i) {
                    fragment.append(i+1);
                    fragment.append(": ");
                    fragment.append(jspLines[i]);
                    fragment.append(System.lineSeparator());
                }
                jspExtract = fragment.toString();
            }
        } catch (IOException ioe) {
            // Can't read files - ignore
        }
    }
    this.jspBeginLineNum = jspBeginLineNum;
}
 
开发者ID:nkasvosve,项目名称:beyondj,代码行数:79,代码来源:JavacErrorDetail.java


注:本文中的org.apache.jasper.JspCompilationContext.getServletJavaFileName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。