本文整理汇总了Java中org.apache.jasper.JspCompilationContext.getResource方法的典型用法代码示例。如果您正苦于以下问题:Java JspCompilationContext.getResource方法的具体用法?Java JspCompilationContext.getResource怎么用?Java JspCompilationContext.getResource使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.jasper.JspCompilationContext
的用法示例。
在下文中一共展示了JspCompilationContext.getResource方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: generateTLDLocation
import org.apache.jasper.JspCompilationContext; //导入方法依赖的package包/类
private TldLocation generateTLDLocation(String uri, JspCompilationContext ctxt)
throws JasperException {
int uriType = TldLocationsCache.uriType(uri);
if (uriType == TldLocationsCache.ABS_URI) {
err.jspError("jsp.error.taglibDirective.absUriCannotBeResolved",
uri);
} else if (uriType == TldLocationsCache.NOROOT_REL_URI) {
uri = ctxt.resolveRelativeUri(uri);
}
if (uri.endsWith(".jar")) {
URL url = null;
try {
url = ctxt.getResource(uri);
} catch (Exception ex) {
err.jspError("jsp.error.tld.unable_to_get_jar", uri, ex
.toString());
}
if (url == null) {
err.jspError("jsp.error.tld.missing_jar", uri);
}
return new TldLocation("META-INF/taglib.tld", url.toString());
} else if (uri.startsWith("/WEB-INF/lib/")
|| uri.startsWith("/WEB-INF/classes/") ||
(uri.startsWith("/WEB-INF/tags/") && uri.endsWith(".tld")
&& !uri.endsWith("implicit.tld"))) {
err.jspError("jsp.error.tld.invalid_tld_file", uri);
}
return new TldLocation(uri);
}
示例2: generateTLDLocation
import org.apache.jasper.JspCompilationContext; //导入方法依赖的package包/类
private String[] generateTLDLocation(String uri, JspCompilationContext ctxt)
throws JasperException {
int uriType = TldLocationsCache.uriType(uri);
if (uriType == TldLocationsCache.ABS_URI) {
err.jspError("jsp.error.taglibDirective.absUriCannotBeResolved",
uri);
} else if (uriType == TldLocationsCache.NOROOT_REL_URI) {
uri = ctxt.resolveRelativeUri(uri);
}
String[] location = new String[2];
location[0] = uri;
if (location[0].endsWith("jar")) {
URL url = null;
try {
url = ctxt.getResource(location[0]);
} catch (Exception ex) {
err.jspError("jsp.error.tld.unable_to_get_jar", location[0], ex
.toString());
}
if (url == null) {
err.jspError("jsp.error.tld.missing_jar", location[0]);
}
location[0] = url.toString();
location[1] = "META-INF/taglib.tld";
}
return location;
}
示例3: generateTLDLocation
import org.apache.jasper.JspCompilationContext; //导入方法依赖的package包/类
private TldLocation generateTLDLocation(String uri, JspCompilationContext ctxt) throws JasperException {
int uriType = TldLocationsCache.uriType(uri);
if (uriType == TldLocationsCache.ABS_URI) {
err.jspError("jsp.error.taglibDirective.absUriCannotBeResolved", uri);
} else if (uriType == TldLocationsCache.NOROOT_REL_URI) {
uri = ctxt.resolveRelativeUri(uri);
}
if (uri.endsWith(".jar")) {
URL url = null;
try {
url = ctxt.getResource(uri);
} catch (Exception ex) {
err.jspError("jsp.error.tld.unable_to_get_jar", uri, ex.toString());
}
if (url == null) {
err.jspError("jsp.error.tld.missing_jar", uri);
}
return new TldLocation("META-INF/taglib.tld", url.toString());
} else if (uri.startsWith("/WEB-INF/lib/") || uri.startsWith("/WEB-INF/classes/")
|| (uri.startsWith("/WEB-INF/tags/") && uri.endsWith(".tld") && !uri.endsWith("implicit.tld"))) {
err.jspError("jsp.error.tld.invalid_tld_file", uri);
}
return new TldLocation(uri);
}
示例4: generateTldResourcePath
import org.apache.jasper.JspCompilationContext; //导入方法依赖的package包/类
private TldResourcePath generateTldResourcePath(String uri,
JspCompilationContext ctxt) throws JasperException {
// TODO: this matches the current implementation but the URL logic looks fishy
// map URI to location per JSP 7.3.6.2
if (uri.indexOf(':') != -1) {
// abs_uri, this was not found in the taglibMap so raise an error
System.out.println("TAG URI : " + uri);
err.jspError("jsp.error.taglibDirective.absUriCannotBeResolved", uri);
} else if (uri.charAt(0) != '/') {
// noroot_rel_uri, resolve against the current JSP page
uri = ctxt.resolveRelativeUri(uri);
try {
// Can't use RequestUtils.normalize since that package is not
// available to Jasper.
uri = (new URI(uri)).normalize().toString();
if (uri.startsWith("../")) {
// Trying to go outside context root
err.jspError("jsp.error.taglibDirective.uriInvalid", uri);
}
} catch (URISyntaxException e) {
err.jspError("jsp.error.taglibDirective.uriInvalid", uri);
}
}
URL url = null;
try {
url = ctxt.getResource(uri);
} catch (Exception ex) {
err.jspError("jsp.error.tld.unable_to_get_jar", uri, ex.toString());
}
if (uri.endsWith(".jar")) {
if (url == null) {
err.jspError("jsp.error.tld.missing_jar", uri);
}
return new TldResourcePath(url, uri, "META-INF/taglib.tld");
} else {
return new TldResourcePath(url, uri);
}
}
示例5: generateTLDLocation
import org.apache.jasper.JspCompilationContext; //导入方法依赖的package包/类
private String[] generateTLDLocation(String uri,
JspCompilationContext ctxt)
throws JasperException {
int uriType = TldScanner.uriType(uri);
if (uriType == TldScanner.ABS_URI) {
err.jspError("jsp.error.taglibDirective.absUriCannotBeResolved",
uri);
} else if (uriType == TldScanner.NOROOT_REL_URI) {
uri = ctxt.resolveRelativeUri(uri);
}
String[] location = new String[2];
location[0] = uri;
if (location[0].endsWith("jar")) {
URL url = null;
try {
url = ctxt.getResource(location[0]);
} catch (Exception ex) {
err.jspError("jsp.error.tld.unable_to_get_jar", location[0],
ex.toString());
}
if (url == null) {
err.jspError("jsp.error.tld.missing_jar", location[0]);
}
location[0] = url.toString();
location[1] = "META-INF/taglib.tld";
}
return location;
}
示例6: generateTLDLocation
import org.apache.jasper.JspCompilationContext; //导入方法依赖的package包/类
private TldLocation generateTLDLocation(String uri, JspCompilationContext ctxt)
throws JasperException {
int uriType = TldLocationsCache.uriType(uri);
if (uriType == TldLocationsCache.ABS_URI) {
err.jspError("jsp.error.taglibDirective.absUriCannotBeResolved",
uri);
} else if (uriType == TldLocationsCache.NOROOT_REL_URI) {
uri = ctxt.resolveRelativeUri(uri);
}
if (uri.endsWith(".jar")) {
URL url = null;
try {
url = ctxt.getResource(uri);
} catch (Exception ex) {
err.jspError("jsp.error.tld.unable_to_get_jar", uri, ex
.toString());
}
if (url == null) {
err.jspError("jsp.error.tld.missing_jar", uri);
}
return new TldLocation("META-INF/taglib.tld", url.toString());
} else {
return new TldLocation(uri);
}
}
示例7: parseImplicitTld
import org.apache.jasper.JspCompilationContext; //导入方法依赖的package包/类
/**
* Parses the JSP version and tlib-version from the implicit.tld at the
* given path.
*/
private void parseImplicitTld(JspCompilationContext ctxt, String path)
throws JasperException {
InputStream is = null;
TreeNode tld = null;
try {
URL uri = ctxt.getResource(path);
if (uri == null) {
// no implicit.tld
return;
}
is = uri.openStream();
/* SJSAS 6384538
tld = new ParserUtils().parseXMLDocument(IMPLICIT_TLD, is);
*/
// START SJSAS 6384538
tld = new ParserUtils().parseXMLDocument(
IMPLICIT_TLD, is, ctxt.getOptions().isValidationEnabled());
// END SJSAS 6384538
} catch (Exception ex) {
throw new JasperException(ex);
} finally {
if (is != null) {
try {
is.close();
} catch (Throwable t) {}
}
}
this.jspversion = tld.findAttribute("version");
Iterator list = tld.findChildren();
while (list.hasNext()) {
TreeNode element = (TreeNode) list.next();
String tname = element.getName();
if ("tlibversion".equals(tname)
|| "tlib-version".equals(tname)) {
this.tlibversion = element.getBody();
} else if ("jspversion".equals(tname)
|| "jsp-version".equals(tname)) {
this.jspversion = element.getBody();
} else if (!"shortname".equals(tname)
&& !"short-name".equals(tname)) {
err.jspError("jsp.error.implicitTld.additionalElements",
path, tname);
}
}
// JSP version in implicit.tld must be 2.0 or greater
Double jspVersionDouble = Double.valueOf(this.jspversion);
if (Double.compare(jspVersionDouble, Constants.JSP_VERSION_2_0) < 0) {
err.jspError("jsp.error.implicitTld.jspVersion", path,
this.jspversion);
}
}
示例8: parseImplicitTld
import org.apache.jasper.JspCompilationContext; //导入方法依赖的package包/类
/**
* Parses the JSP version and tlib-version from the implicit.tld at the
* given path.
*/
private void parseImplicitTld(JspCompilationContext ctxt, String path)
throws JasperException {
InputStream is = null;
TreeNode tld = null;
try {
URL uri = ctxt.getResource(path);
if (uri == null) {
// no implicit.tld
return;
}
is = uri.openStream();
/* SJSAS 6384538
tld = new ParserUtils().parseXMLDocument(IMPLICIT_TLD, is);
*/
// START SJSAS 6384538
boolean blockExternal = Boolean.parseBoolean(ctxt.getServletContext()
.getInitParameter(Constants.XML_BLOCK_EXTERNAL_INIT_PARAM));
tld = new ParserUtils(blockExternal).parseXMLDocument(
IMPLICIT_TLD, is, ctxt.getOptions().isValidationEnabled());
// END SJSAS 6384538
} catch (Exception ex) {
throw new JasperException(ex);
} finally {
if (is != null) {
try {
is.close();
} catch (Throwable t) {}
}
}
this.jspversion = tld.findAttribute("version");
Iterator list = tld.findChildren();
while (list.hasNext()) {
TreeNode element = (TreeNode) list.next();
String tname = element.getName();
if ("tlibversion".equals(tname)
|| "tlib-version".equals(tname)) {
this.tlibversion = element.getBody();
} else if ("jspversion".equals(tname)
|| "jsp-version".equals(tname)) {
this.jspversion = element.getBody();
} else if (!"shortname".equals(tname)
&& !"short-name".equals(tname)) {
err.jspError("jsp.error.implicitTld.additionalElements",
path, tname);
}
}
// JSP version in implicit.tld must be 2.0 or greater
Double jspVersionDouble = Double.valueOf(this.jspversion);
if (Double.compare(jspVersionDouble, Constants.JSP_VERSION_2_0) < 0) {
err.jspError("jsp.error.implicitTld.jspVersion", path,
this.jspversion);
}
}