Example usage for javax.servlet.jsp JspException toString

List of usage examples for javax.servlet.jsp JspException toString

Introduction

In this page you can find the example usage for javax.servlet.jsp JspException toString.

Prototype

public String toString() 

Source Link

Document

Returns a short description of this throwable.

Usage

From source file:jp.terasoluna.fw.web.struts.taglib.LinkTag.java

/**
 * <p>URLLbVp_ID?B</p>//from   w ww.  j av  a 2s .co m
 *
 * <p>zbgX|bg?A<code>Struts 1.2.4</code> 
 * <code>LinkTag.calculate()</code> R?[hRs?[?X?B
 * <code>Struts</code> o?[W?X??
 * Kv??B</p>
 *
 * @return ???w
 * @exception JspException G?[?
 */
@SuppressWarnings("unchecked")
@Override
protected String calculateURL() throws JspException {

    // Identify the parameters we will add to the completed URL
    Map<String, String> params = TagUtils.getInstance().computeParameters(pageContext, paramId, paramName,
            paramProperty, paramScope, name, property, scope, transaction);

    // ========== ?yg??z?==========
    if (params == null) {
        params = new HashMap<String, String>();
    }

    //_ID??????B
    forward = RequestUtil.deleteUrlParam(forward, RANDOM_ID_KEY);
    href = RequestUtil.deleteUrlParam(href, RANDOM_ID_KEY);
    page = RequestUtil.deleteUrlParam(page, RANDOM_ID_KEY);
    action = RequestUtil.deleteUrlParam(action, RANDOM_ID_KEY);

    //p??[^}bv_ID?B
    params.put(RANDOM_ID_KEY, RandomUtil.generateRandomID());

    // if "indexed=true", add "index=x" parameter to query string
    // * @since Struts 1.1
    if (indexed) {

        // look for outer iterate tag
        IterateTag iterateTag = (IterateTag) findAncestorWithClass(this, IterateTag.class);
        if (iterateTag == null) {
            // iterateTagbodygp??O
            JspException e = new JspException(messages.getMessage("indexed.noEnclosingIterate"));
            TagUtils.getInstance().saveException(pageContext, e);

            log.error("iterateTag is null.");
            throw e;
        }

        if (indexId != null) {
            params.put(indexId, Integer.toString(iterateTag.getIndex()));
        } else {
            params.put("index", Integer.toString(iterateTag.getIndex()));
        }
    }
    // ========== ?yg??z?==========

    String url = null;
    try {
        url = TagUtils.getInstance().computeURLWithCharEncoding(pageContext, forward, href, page, action,
                module, params, anchor, false, useLocalEncoding);
    } catch (MalformedURLException e) {
        TagUtils.getInstance().saveException(pageContext, e);

        log.error("Malformed URL has occurred.");
        throw new JspException(messages.getMessage("rewrite.url", e.toString()));
    }
    return (url);

}

From source file:org.rhq.enterprise.gui.legacy.taglib.display.TableTag.java

/**
 * Use the jstl expression expression language to evaluate a field.
 *
 * @param  name/*from  w  w w  . j  av a2  s. co  m*/
 * @param  value
 * @param  type  The Class type of the object you expect.
 *
 * @return The object found
 *
 * @throws NullAttributeException Thrown if the value is null.
 */
private Object evalAttr(String name, String value, Class type) throws JspTagException {
    try {
        return ExpressionUtil.evalNotNull("display", name, value, type, this, pageContext);
    } catch (NullAttributeException ne) {
        throw new JspTagException("Attribute " + name + " not found in TableTag");
    } catch (JspException je) {
        throw new JspTagException(je.toString());
    }
}

From source file:us.mn.state.health.lims.taglib.OptionsCollectionTag.java

/**
 * Process the start of this tag.// w ww .j av  a  2  s.  com
 * 
 * @exception JspException
 *                if a JSP exception has occurred
 */
public int doStartTag() throws JspException {
    // Acquire the select tag we are associated with
    SelectTag selectTag = (SelectTag) pageContext.getAttribute(Constants.SELECT_KEY);

    if (selectTag == null) {
        JspException e = new JspException(messages.getMessage("optionsCollectionTag.select"));
        TagUtils.getInstance().saveException(pageContext, e);
        throw e;
    }

    // Acquire the collection containing our options
    Object collection = TagUtils.getInstance().lookup(pageContext, name, property, null);

    if (collection == null) {
        JspException e = new JspException(messages.getMessage("optionsCollectionTag.collection"));
        TagUtils.getInstance().saveException(pageContext, e);
        throw e;
    }

    // Acquire an iterator over the options collection
    Iterator iter = getIterator(collection);

    //bugzilla 2154
    LogEvent.logDebug("OptionsCollectionTag", "doStartTag()", "Filter Properties = " + filterProperty);
    LogEvent.logDebug("OptionsCollectionTag", "doStartTag()", "Filter Values = " + filterValue);

    StringBuffer sb = new StringBuffer();

    if (isAllowEdits() && isShowDefault()) {
        addOption(sb, "", "", false);
    }

    boolean first = true;

    // Render the options
    while (iter.hasNext()) {

        Object bean = iter.next();
        // Get the label for this option
        Object beanLabel = getProperty(bean, label);
        // Get the value for this option
        Object beanValue = getProperty(bean, value);

        String stringLabel = beanLabel.toString();
        String stringValue = beanValue.toString();

        boolean filterOkay = true;
        boolean matchOkay = true;
        Object beanFilter;
        // We only check the filter and match properties if the current
        // option is NOT a match.
        if (!selectTag.isMatched(stringValue)) {
            if (filterProperties != null) {
                for (int i = 0; i < filterProperties.length; ++i) {
                    try {
                        //bugzilla 2154
                        LogEvent.logDebug("OptionsCollectionTag", "doStartTag()",
                                "Checking filter: " + filterValues[i]);
                        beanFilter = PropertyUtils.getNestedProperty(bean, filterProperties[i]);
                        //bugzilla 2154
                        LogEvent.logDebug("OptionsCollectionTag", "doStartTag()",
                                "Bean property: " + beanFilter.toString());
                    } catch (Exception e) {
                        //bugzilla 2154
                        LogEvent.logError("OptionsCollectionTag", "doStartTag()", e.toString());
                        throw new JspException("Failed to retrieve property from bean.", e);
                    }
                    if (beanFilter != null && beanFilter.toString().equals(filterValues[i])) {
                        //bugzilla 2154
                        LogEvent.logDebug("OptionsCollectionTag", "doStartTag()",
                                "Filter failed for " + filterProperties[i] + ".");
                        // Filter failed, so break
                        filterOkay = false;
                        break;
                    }
                }
            }

            if (matchProperties != null) {
                for (int i = 0; i < matchProperties.length; ++i) {
                    try {
                        //bugzilla 2154
                        LogEvent.logDebug("OptionsCollectionTag", "doStartTag()",
                                "Checking filter: " + matchProperties[i] + "!=" + matchValues[i]);

                        beanFilter = PropertyUtils.getNestedProperty(bean, matchProperties[i]);
                        //bugzilla 2154
                        LogEvent.logDebug("OptionsCollectionTag", "doStartTag()",
                                "Bean property: " + matchProperties[i] + "=" + beanFilter.toString());
                    } catch (Exception e) {
                        //bugzilla 2154
                        LogEvent.logError("OptionsCollectionTag", "doStartTag()", e.toString());
                        throw new JspException("Failed to retrieve property from bean.", e);
                    }

                    if (beanFilter != null && !beanFilter.toString().equals(matchValues[i])) {
                        //bugzilla 2154
                        LogEvent.logDebug("OptionsCollectionTag", "doStartTag()",
                                "Match failed for " + matchProperties[i] + ".");
                        // Match failed, so break
                        matchOkay = false;
                        break;
                    }
                }
            }
        }

        if (filterOkay && matchOkay) {
            //bugzilla 2154
            LogEvent.logDebug("OptionsCollectionTag", "doStartTag()",
                    "In OptionsTag label = " + stringLabel + " value = " + stringValue);

            if (isAllowEdits()) {
                addOption(sb, stringLabel, stringValue, selectTag.isMatched(stringValue));
            } else {
                //bugzilla 2154
                LogEvent.logDebug("OptionsCollectionTag", "doStartTag()",
                        "In OptionsTag is matched = " + selectTag.isMatched(stringValue));
                if (selectTag.isMatched(stringValue)) {
                    if (!first) {
                        stringLabel = ", " + stringLabel;
                    }
                    first = false;
                    if (getStyleClass() != null) {
                        stringLabel = "<span class=" + getStyleClass() + ">" + stringLabel + "</span>";
                    }
                    sb.append(stringLabel);
                    sb.append("\r\n<INPUT type=\"hidden\"  name=\"" + selectTag.getProperty() + "\""
                            + " value=\"" + stringValue + "\"" + ">");
                }
            }
        }
    }
    //bugzilla 2154
    LogEvent.logDebug("OptionsCollectionTag", "doStartTag()", "In OptionsTag output = " + sb.toString());

    // Render this element to our writer
    TagUtils.getInstance().write(pageContext, sb.toString());

    return SKIP_BODY;
}