Search in sources :

Example 61 with JasperException

use of org.apache.jasper.JasperException in project tomcat70 by apache.

the class JspRuntimeLibrary method handleSetProperty.

public static void handleSetProperty(Object bean, String prop, short value) throws JasperException {
    try {
        Method method = getWriteMethod(bean.getClass(), prop);
        method.invoke(bean, new Object[] { Short.valueOf(value) });
    } catch (Exception ex) {
        Throwable thr = ExceptionUtils.unwrapInvocationTargetException(ex);
        ExceptionUtils.handleThrowable(thr);
        throw new JasperException(ex);
    }
}
Also used : JasperException(org.apache.jasper.JasperException) Method(java.lang.reflect.Method) ServletException(javax.servlet.ServletException) JspException(javax.servlet.jsp.JspException) IOException(java.io.IOException) JasperException(org.apache.jasper.JasperException)

Example 62 with JasperException

use of org.apache.jasper.JasperException in project tomcat70 by apache.

the class JspRuntimeLibrary method handleSetProperty.

public static void handleSetProperty(Object bean, String prop, int value) throws JasperException {
    try {
        Method method = getWriteMethod(bean.getClass(), prop);
        method.invoke(bean, new Object[] { Integer.valueOf(value) });
    } catch (Exception ex) {
        Throwable thr = ExceptionUtils.unwrapInvocationTargetException(ex);
        ExceptionUtils.handleThrowable(thr);
        throw new JasperException(ex);
    }
}
Also used : JasperException(org.apache.jasper.JasperException) Method(java.lang.reflect.Method) ServletException(javax.servlet.ServletException) JspException(javax.servlet.jsp.JspException) IOException(java.io.IOException) JasperException(org.apache.jasper.JasperException)

Example 63 with JasperException

use of org.apache.jasper.JasperException in project tomcat70 by apache.

the class JspRuntimeLibrary method handleSetProperty.

public static void handleSetProperty(Object bean, String prop, boolean value) throws JasperException {
    try {
        Method method = getWriteMethod(bean.getClass(), prop);
        method.invoke(bean, new Object[] { Boolean.valueOf(value) });
    } catch (Exception ex) {
        Throwable thr = ExceptionUtils.unwrapInvocationTargetException(ex);
        ExceptionUtils.handleThrowable(thr);
        throw new JasperException(ex);
    }
}
Also used : JasperException(org.apache.jasper.JasperException) Method(java.lang.reflect.Method) ServletException(javax.servlet.ServletException) JspException(javax.servlet.jsp.JspException) IOException(java.io.IOException) JasperException(org.apache.jasper.JasperException)

Example 64 with JasperException

use of org.apache.jasper.JasperException in project tomcat70 by apache.

the class JspRuntimeLibrary method handleSetPropertyExpression.

// __end lookupReadMethodMethod
// handles <jsp:setProperty> with EL expression for 'value' attribute
/**
 * Use proprietaryEvaluate
 *    public static void handleSetPropertyExpression(Object bean,
 *        String prop, String expression, PageContext pageContext,
 *        VariableResolver variableResolver, FunctionMapper functionMapper )
 *        throws JasperException
 *    {
 *        try {
 *            Method method = getWriteMethod(bean.getClass(), prop);
 *            method.invoke(bean, new Object[] {
 *                pageContext.getExpressionEvaluator().evaluate(
 *                    expression,
 *                    method.getParameterTypes()[0],
 *                    variableResolver,
 *                    functionMapper,
 *                    null )
 *            });
 *        } catch (Exception ex) {
 *            throw new JasperException(ex);
 *        }
 *    }
 */
public static void handleSetPropertyExpression(Object bean, String prop, String expression, PageContext pageContext, ProtectedFunctionMapper functionMapper) throws JasperException {
    try {
        Method method = getWriteMethod(bean.getClass(), prop);
        method.invoke(bean, new Object[] { PageContextImpl.proprietaryEvaluate(expression, method.getParameterTypes()[0], pageContext, functionMapper, false) });
    } catch (Exception ex) {
        Throwable thr = ExceptionUtils.unwrapInvocationTargetException(ex);
        ExceptionUtils.handleThrowable(thr);
        throw new JasperException(ex);
    }
}
Also used : JasperException(org.apache.jasper.JasperException) Method(java.lang.reflect.Method) ServletException(javax.servlet.ServletException) JspException(javax.servlet.jsp.JspException) IOException(java.io.IOException) JasperException(org.apache.jasper.JasperException)

Example 65 with JasperException

use of org.apache.jasper.JasperException in project tomcat70 by apache.

the class TagLibraryInfoImpl method createTagInfo.

private TagInfo createTagInfo(TreeNode elem, String jspVersion) throws JasperException {
    String tagName = null;
    String tagClassName = null;
    String teiClassName = null;
    /*
         * Default body content for JSP 1.2 tag handlers (<body-content> has
         * become mandatory in JSP 2.0, because the default would be invalid for
         * simple tag handlers)
         */
    String bodycontent = "JSP";
    String info = null;
    String displayName = null;
    String smallIcon = null;
    String largeIcon = null;
    boolean dynamicAttributes = false;
    Vector<TagAttributeInfo> attributeVector = new Vector<TagAttributeInfo>();
    Vector<TagVariableInfo> variableVector = new Vector<TagVariableInfo>();
    Iterator<TreeNode> list = elem.findChildren();
    while (list.hasNext()) {
        TreeNode element = list.next();
        String tname = element.getName();
        if ("name".equals(tname)) {
            tagName = element.getBody();
        } else if ("tagclass".equals(tname) || "tag-class".equals(tname)) {
            tagClassName = element.getBody();
        } else if ("teiclass".equals(tname) || "tei-class".equals(tname)) {
            teiClassName = element.getBody();
        } else if ("bodycontent".equals(tname) || "body-content".equals(tname)) {
            bodycontent = element.getBody();
        } else if ("display-name".equals(tname)) {
            displayName = element.getBody();
        } else if ("small-icon".equals(tname)) {
            smallIcon = element.getBody();
        } else if ("large-icon".equals(tname)) {
            largeIcon = element.getBody();
        } else if ("icon".equals(tname)) {
            TreeNode icon = element.findChild("small-icon");
            if (icon != null) {
                smallIcon = icon.getBody();
            }
            icon = element.findChild("large-icon");
            if (icon != null) {
                largeIcon = icon.getBody();
            }
        } else if ("info".equals(tname) || "description".equals(tname)) {
            info = element.getBody();
        } else if ("variable".equals(tname)) {
            variableVector.addElement(createVariable(element));
        } else if ("attribute".equals(tname)) {
            attributeVector.addElement(createAttribute(element, jspVersion));
        } else if ("dynamic-attributes".equals(tname)) {
            dynamicAttributes = JspUtil.booleanValue(element.getBody());
        } else if ("example".equals(tname)) {
        // Ignored elements
        } else if ("tag-extension".equals(tname)) {
        // Ignored
        } else {
            if (log.isWarnEnabled()) {
                log.warn(Localizer.getMessage("jsp.warning.unknown.element.in.tag", tname));
            }
        }
    }
    TagExtraInfo tei = null;
    if (teiClassName != null && !teiClassName.equals("")) {
        try {
            Class<?> teiClass = ctxt.getClassLoader().loadClass(teiClassName);
            tei = (TagExtraInfo) teiClass.newInstance();
        } catch (Exception e) {
            err.jspError(e, "jsp.error.teiclass.instantiation", teiClassName);
        }
    }
    TagAttributeInfo[] tagAttributeInfo = new TagAttributeInfo[attributeVector.size()];
    attributeVector.copyInto(tagAttributeInfo);
    TagVariableInfo[] tagVariableInfos = new TagVariableInfo[variableVector.size()];
    variableVector.copyInto(tagVariableInfos);
    TagInfo taginfo = new TagInfo(tagName, tagClassName, bodycontent, info, this, tei, tagAttributeInfo, displayName, smallIcon, largeIcon, tagVariableInfos, dynamicAttributes);
    return taginfo;
}
Also used : TagAttributeInfo(javax.servlet.jsp.tagext.TagAttributeInfo) TagVariableInfo(javax.servlet.jsp.tagext.TagVariableInfo) JasperException(org.apache.jasper.JasperException) FileNotFoundException(java.io.FileNotFoundException) TreeNode(org.apache.jasper.xmlparser.TreeNode) TagExtraInfo(javax.servlet.jsp.tagext.TagExtraInfo) TagInfo(javax.servlet.jsp.tagext.TagInfo) Vector(java.util.Vector)

Aggregations

JasperException (org.apache.jasper.JasperException)80 IOException (java.io.IOException)61 Method (java.lang.reflect.Method)28 ServletException (javax.servlet.ServletException)21 FileNotFoundException (java.io.FileNotFoundException)19 ServletException (jakarta.servlet.ServletException)18 JspException (javax.servlet.jsp.JspException)18 JspException (jakarta.servlet.jsp.JspException)15 File (java.io.File)8 SAXException (org.xml.sax.SAXException)7 HashMap (java.util.HashMap)6 FileOutputStream (java.io.FileOutputStream)5 InputStream (java.io.InputStream)5 InputStreamReader (java.io.InputStreamReader)4 URL (java.net.URL)4 ArrayList (java.util.ArrayList)4 TreeNode (org.apache.jasper.xmlparser.TreeNode)4 TagInfo (jakarta.servlet.jsp.tagext.TagInfo)3 BufferedOutputStream (java.io.BufferedOutputStream)3 BufferedReader (java.io.BufferedReader)3