use of org.apache.jasper.JasperException in project tomcat by apache.
the class JspRuntimeLibrary method handleSetProperty.
public static void handleSetProperty(Object bean, String prop, float value) throws JasperException {
try {
Method method = getWriteMethod(bean.getClass(), prop);
method.invoke(bean, new Object[] { Float.valueOf(value) });
} catch (Exception ex) {
Throwable thr = ExceptionUtils.unwrapInvocationTargetException(ex);
ExceptionUtils.handleThrowable(thr);
throw new JasperException(ex);
}
}
use of org.apache.jasper.JasperException in project tomcat by apache.
the class SmapUtil method generateSmap.
// *********************************************************************
// Public entry points
/**
* Generates an appropriate SMAP representing the current compilation
* context. (JSR-045.)
*
* @param ctxt Current compilation context
* @param pageNodes The current JSP page
* @return a SMAP for the page
* @throws IOException Error writing SMAP
*/
public static Map<String, SmapStratum> generateSmap(JspCompilationContext ctxt, Node.Nodes pageNodes) throws IOException {
Map<String, SmapStratum> smapInfo = new HashMap<>();
// Scan the nodes for presence of Jasper generated inner classes
PreScanVisitor psVisitor = new PreScanVisitor();
try {
pageNodes.visit(psVisitor);
} catch (JasperException ex) {
}
HashMap<String, SmapStratum> map = psVisitor.getMap();
// Assemble info about our own stratum (JSP) using JspLineMap
SmapStratum s = new SmapStratum();
// Map out Node.Nodes
evaluateNodes(pageNodes, s, map, ctxt.getOptions().getMappedFile());
s.optimizeLineSection();
s.setOutputFileName(unqualify(ctxt.getServletJavaFileName()));
String classFileName = ctxt.getClassFileName();
s.setClassFileName(classFileName);
smapInfo.put(ctxt.getFQCN(), s);
if (ctxt.getOptions().isSmapDumped()) {
File outSmap = new File(classFileName + ".smap");
PrintWriter so = new PrintWriter(new OutputStreamWriter(new FileOutputStream(outSmap), SMAP_ENCODING));
so.print(s.getSmapString());
so.close();
}
for (Map.Entry<String, SmapStratum> entry : map.entrySet()) {
String innerClass = entry.getKey();
s = entry.getValue();
s.optimizeLineSection();
s.setOutputFileName(unqualify(ctxt.getServletJavaFileName()));
String innerClassFileName = classFileName.substring(0, classFileName.indexOf(".class")) + '$' + innerClass + ".class";
s.setClassFileName(innerClassFileName);
smapInfo.put(ctxt.getFQCN() + "." + innerClass, s);
if (ctxt.getOptions().isSmapDumped()) {
File outSmap = new File(innerClassFileName + ".smap");
PrintWriter so = new PrintWriter(new OutputStreamWriter(new FileOutputStream(outSmap), SMAP_ENCODING));
so.print(s.getSmapString());
so.close();
}
}
return smapInfo;
}
use of org.apache.jasper.JasperException in project tomcat by apache.
the class TldCache method getTaglibXml.
public TaglibXml getTaglibXml(TldResourcePath tldResourcePath) throws JasperException {
TaglibXmlCacheEntry cacheEntry = tldResourcePathTaglibXmlMap.get(tldResourcePath);
if (cacheEntry == null) {
return null;
}
long[] lastModified = getLastModified(tldResourcePath);
if (lastModified[0] != cacheEntry.getWebAppPathLastModified() || lastModified[1] != cacheEntry.getEntryLastModified()) {
synchronized (cacheEntry) {
if (lastModified[0] != cacheEntry.getWebAppPathLastModified() || lastModified[1] != cacheEntry.getEntryLastModified()) {
// Re-parse TLD
TaglibXml updatedTaglibXml;
try {
updatedTaglibXml = tldParser.parse(tldResourcePath);
} catch (IOException | SAXException e) {
throw new JasperException(e);
}
cacheEntry.setTaglibXml(updatedTaglibXml);
cacheEntry.setWebAppPathLastModified(lastModified[0]);
cacheEntry.setEntryLastModified(lastModified[1]);
}
}
}
return cacheEntry.getTaglibXml();
}
use of org.apache.jasper.JasperException in project tomcat by apache.
the class TagLibraryInfoImpl method createValidator.
private TagLibraryValidator createValidator(ValidatorXml validatorXml) throws JasperException {
if (validatorXml == null) {
return null;
}
String validatorClass = validatorXml.getValidatorClass();
if (validatorClass == null || validatorClass.isEmpty()) {
return null;
}
Map<String, Object> initParams = new Hashtable<>(validatorXml.getInitParams());
try {
Class<?> tlvClass = ctxt.getClassLoader().loadClass(validatorClass);
TagLibraryValidator tlv = (TagLibraryValidator) tlvClass.getConstructor().newInstance();
tlv.setInitParameters(initParams);
return tlv;
} catch (Exception e) {
err.jspError(e, "jsp.error.tlvclass.instantiation", validatorClass);
return null;
}
}
use of org.apache.jasper.JasperException in project tomcat by apache.
the class TagLibraryInfoImpl method createTagInfo.
private TagInfo createTagInfo(TagXml tagXml) throws JasperException {
String teiClassName = tagXml.getTeiClass();
TagExtraInfo tei = null;
if (teiClassName != null && !teiClassName.isEmpty()) {
try {
Class<?> teiClass = ctxt.getClassLoader().loadClass(teiClassName);
tei = (TagExtraInfo) teiClass.getConstructor().newInstance();
} catch (Exception e) {
err.jspError(e, "jsp.error.teiclass.instantiation", teiClassName);
}
}
List<TagAttributeInfo> attributeInfos = tagXml.getAttributes();
List<TagVariableInfo> variableInfos = tagXml.getVariables();
return new TagInfo(tagXml.getName(), tagXml.getTagClass(), tagXml.getBodyContent(), tagXml.getInfo(), this, tei, attributeInfos.toArray(new TagAttributeInfo[0]), tagXml.getDisplayName(), tagXml.getSmallIcon(), tagXml.getLargeIcon(), variableInfos.toArray(new TagVariableInfo[0]), tagXml.hasDynamicAttributes());
}
Aggregations