本文整理汇总了Java中org.apache.jasper.JspCompilationContext.getResourceAsStream方法的典型用法代码示例。如果您正苦于以下问题:Java JspCompilationContext.getResourceAsStream方法的具体用法?Java JspCompilationContext.getResourceAsStream怎么用?Java JspCompilationContext.getResourceAsStream使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.jasper.JspCompilationContext
的用法示例。
在下文中一共展示了JspCompilationContext.getResourceAsStream方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getInputStream
import org.apache.jasper.JspCompilationContext; //导入方法依赖的package包/类
public static InputStream getInputStream(String fname, JarFile jarFile,
JspCompilationContext ctxt, ErrorDispatcher err)
throws JasperException, IOException {
InputStream in = null;
if (jarFile != null) {
String jarEntryName = fname.substring(1, fname.length());
ZipEntry jarEntry = jarFile.getEntry(jarEntryName);
if (jarEntry == null) {
throw new FileNotFoundException(Localizer.getMessage(
"jsp.error.file.not.found", fname));
}
in = jarFile.getInputStream(jarEntry);
} else {
in = ctxt.getResourceAsStream(fname);
}
if (in == null) {
throw new FileNotFoundException(Localizer.getMessage(
"jsp.error.file.not.found", fname));
}
return in;
}
示例2: getInputStream
import org.apache.jasper.JspCompilationContext; //导入方法依赖的package包/类
public static InputStream getInputStream(String fname, JarFile jarFile,
JspCompilationContext ctxt,
ErrorDispatcher err)
throws JasperException, IOException {
InputStream in = null;
if (jarFile != null) {
String jarEntryName = fname.substring(1, fname.length());
ZipEntry jarEntry = jarFile.getEntry(jarEntryName);
if (jarEntry == null) {
err.jspError("jsp.error.file.not.found", fname);
}
in = jarFile.getInputStream(jarEntry);
} else {
in = ctxt.getResourceAsStream(fname);
}
if (in == null) {
err.jspError("jsp.error.file.not.found", fname);
}
return in;
}
示例3: getInputStream
import org.apache.jasper.JspCompilationContext; //导入方法依赖的package包/类
public static InputStream getInputStream(String fname, JarFile jarFile, JspCompilationContext ctxt,
ErrorDispatcher err) throws JasperException, IOException {
InputStream in = null;
if (jarFile != null) {
String jarEntryName = fname.substring(1, fname.length());
ZipEntry jarEntry = jarFile.getEntry(jarEntryName);
if (jarEntry == null) {
throw new FileNotFoundException(Localizer.getMessage("jsp.error.file.not.found", fname));
}
in = jarFile.getInputStream(jarEntry);
} else {
in = ctxt.getResourceAsStream(fname);
}
if (in == null) {
throw new FileNotFoundException(Localizer.getMessage("jsp.error.file.not.found", fname));
}
return in;
}
示例4: getInputStream
import org.apache.jasper.JspCompilationContext; //导入方法依赖的package包/类
public static InputStream getInputStream(String fname, Jar jar,
JspCompilationContext ctxt) throws IOException {
InputStream in = null;
if (jar != null) {
String jarEntryName = fname.substring(1, fname.length());
in = jar.getInputStream(jarEntryName);
} else {
in = ctxt.getResourceAsStream(fname);
}
if (in == null) {
throw new FileNotFoundException(Localizer.getMessage(
"jsp.error.file.not.found", fname));
}
return in;
}
示例5: getInputStream
import org.apache.jasper.JspCompilationContext; //导入方法依赖的package包/类
public static InputStream getInputStream(String fname, JarFile jarFile,
JspCompilationContext ctxt,
ErrorDispatcher err)
throws JasperException, IOException {
InputStream in = null;
if (jarFile != null) {
String jarEntryName = fname.substring(1, fname.length());
ZipEntry jarEntry = jarFile.getEntry(jarEntryName);
if (jarEntry == null) {
err.jspError("jsp.error.file.not.found", fname);
}
in = jarFile.getInputStream(jarEntry);
} else {
in = ctxt.getResourceAsStream(fname);
}
if (in == null) {
err.jspError("jsp.error.file.not.found", fname);
}
return in;
}
示例6: getInputStream
import org.apache.jasper.JspCompilationContext; //导入方法依赖的package包/类
public static InputStream getInputStream(String fname, JarFile jarFile,
JspCompilationContext ctxt, ErrorDispatcher err)
throws JasperException, IOException {
InputStream in = null;
if (jarFile != null) {
String jarEntryName = fname.substring(1, fname.length());
ZipEntry jarEntry = jarFile.getEntry(jarEntryName);
if (jarEntry == null) {
err.jspError("jsp.error.file.not.found", fname);
}
in = jarFile.getInputStream(jarEntry);
} else {
in = ctxt.getResourceAsStream(fname);
}
if (in == null) {
err.jspError("jsp.error.file.not.found", fname);
}
return in;
}
示例7: getInputSource
import org.apache.jasper.JspCompilationContext; //导入方法依赖的package包/类
public static InputSource getInputSource(String fname, Jar jar, JspCompilationContext ctxt)
throws IOException {
InputSource source;
if (jar != null) {
String jarEntryName = fname.substring(1, fname.length());
source = new InputSource(jar.getInputStream(jarEntryName));
source.setSystemId(jar.getURL(jarEntryName));
} else {
source = new InputSource(ctxt.getResourceAsStream(fname));
source.setSystemId(ctxt.getResource(fname).toExternalForm());
}
return source;
}
示例8: 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;
}