Example usage for javax.servlet.jsp JspException getMessage

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

Introduction

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

Prototype

public String getMessage() 

Source Link

Document

Returns the detail message string of this throwable.

Usage

From source file:org.apache.struts.taglib.TestTagUtils.java

public void testActionMessages_getActionMessages_PageContext_String3() {
    request.setAttribute("foo", "bar");

    try {//from  w  w w . j  a va2  s  .  c o m
        ActionMessages messages = tagutils.getActionMessages(pageContext, "foo");

        assertNotNull("messages should not be null", messages);
        assertNotNull("messages prop should not be null", messages.get("prop"));

        String key = null;
        int i = 0;

        for (Iterator iter = messages.get(ActionMessages.GLOBAL_MESSAGE); iter.hasNext();) {
            ActionMessage message = (ActionMessage) iter.next();

            key = message.getKey();

            Object[] values = message.getValues();

            assertNull(values);
            i++;
        }

        assertEquals("only 1 message", i, 1);
        assertEquals("key should match", key, "bar");
    } catch (JspException e) {
        fail(e.getMessage());
    }
}

From source file:org.apache.struts.taglib.TestTagUtils.java

public void testActionMessages_getActionMessages_PageContext_String4() {
    String[] vals = new String[] { "bar", "baz" };

    request.setAttribute("foo", vals);

    try {/*www  .  ja v a2 s.c o  m*/
        ActionMessages messages = tagutils.getActionMessages(pageContext, "foo");

        assertNotNull("messages should not be null", messages);
        assertNotNull("messages prop should not be null", messages.get("prop"));

        String key = null;
        int i = 0;

        for (Iterator iter = messages.get(ActionMessages.GLOBAL_MESSAGE); iter.hasNext();) {
            ActionMessage message = (ActionMessage) iter.next();

            key = message.getKey();

            Object[] values = message.getValues();

            assertNull((values));
            assertEquals("1st key should match", key, vals[i]);
            i++;
        }

        assertEquals("only 1 message", i, 2);
    } catch (JspException e) {
        fail(e.getMessage());
    }
}

From source file:org.apache.struts.taglib.TestTagUtils.java

public void testActionMessages_getActionMessages_PageContext_String6() {
    ActionMessages actionMessages = new ActionMessages();

    actionMessages.add("prop", new ActionMessage("key.key"));
    request.setAttribute("messages", actionMessages);

    try {//from   ww  w. j  a  va 2  s .co  m
        ActionMessages messages = tagutils.getActionMessages(pageContext, "does-not-exist");

        assertNotNull("messages should not be null", messages);
        assertNotNull("messages prop should not be null", messages.get("prop"));

        for (Iterator iter = messages.get("prop"); iter.hasNext();) {
            fail("Should not have any messages for does-not-exist");
        }
    } catch (JspException e) {
        fail(e.getMessage());
    }
}

From source file:org.apache.struts.taglib.TestTagUtils.java

public void test_Object_lookup_PageContext_String__String1() {
    pageContext.setAttribute("bean", new MockFormBean());

    try {//  ww w.  j a  v  a 2  s. c o m
        Object val = tagutils.lookup(pageContext, "bean", null);

        assertNotNull((val));
    } catch (JspException e) {
        fail("bean not found:" + e.getMessage());
    }
}

From source file:org.apache.struts.taglib.TestTagUtils.java

public void test_Object_lookup_PageContext_String__String2() {
    pageContext.setAttribute("bean", new MockFormBean());

    try {//from  w  w w .  j av a2s .com
        Object val = tagutils.lookup(pageContext, "bean", "page");

        assertNotNull((val));
    } catch (JspException e) {
        fail("bean not found:" + e.getMessage());
    }
}

From source file:org.apache.tiles.jsp.context.JspTilesRequestContext.java

/** {@inheritDoc} */
public void include(String path) throws IOException {
    try {// w ww  . j av a2s.  c  o m
        JspUtil.doInclude(pageContext, path, false);
    } catch (JspException e) {
        LOG.error("JSPException while including path '" + path + "'. ", e);
        throw new IOException("JSPException while including path '" + path + "'. " + e.getMessage());
    }
}

From source file:org.hdiv.taglib.html.HiddenTagHDIV.java

/**
 * Generate the required input tag, followed by the optional rendered text.
 * Support for <code>write</code> property since Struts 1.1.
 * /*ww w.  j  a v a 2  s  . c o  m*/
 * @exception JspException if a JSP exception has occurred
 * @see org.hdiv.dataComposer.IDataComposer#compose(String, String, boolean)
 */
public int doStartTag() throws JspException {

    try {
        String hiddenValue = value;
        Object lookupValue = null;

        if (value == null) {
            // locate and return the specified property of the specified bean
            lookupValue = TagUtils.getInstance().lookup(pageContext, name, property, null);

            if (lookupValue != null) {
                hiddenValue = lookupValue.toString();
            }
        }

        HttpServletRequest request = (HttpServletRequest) this.pageContext.getRequest();
        IDataComposer dataComposer = HDIVUtil.getDataComposer(request);
        this.encodedValue = dataComposer.compose(prepareName(), hiddenValue, false);

        // Render the result to the output writer
        TagUtils.getInstance().write(this.pageContext, this.renderInputElement());

        // Is rendering the value separately requested?
        if (!write) {
            return (EVAL_BODY_TAG);
        }

        // Calculate the value to be rendered separately
        // * @since Struts 1.1
        String results = null;
        if (value != null) {
            results = TagUtils.getInstance().filter(value);
        } else {
            if (lookupValue == null) {
                results = "";
            } else {
                results = TagUtils.getInstance().filter(lookupValue.toString());
            }
        }

        // Render the result to the output writer
        TagUtils.getInstance().write(pageContext, results);
        return (EVAL_BODY_TAG);

    } catch (JspException e) {
        log.debug(e.getMessage());
        throw e;
    }
}

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

public String replacePropertyIfPossible(String input, PageContext pageContext) {
    int i = input.indexOf("_property:");
    if (i >= 0) {
        String oc = input;//from  www. ja  va 2  s.c  om
        TableTag tt = (TableTag) getParent();
        int pos = input.indexOf(":", i);
        int pos2 = input.indexOf(":", pos + 1);
        // TODO add some error checking
        String prop = input.substring(pos + 1, pos2);

        String rep;
        try {
            Object o = tt.lookup(pageContext, "smartRow", prop, null, true);
            rep = o.toString();
            oc = input.replace("_property:" + prop + ":", rep);
        } catch (JspException e) {
            log.warn("Can't replace the _property on " + input + ": " + e.getMessage());
        }
        return oc;
    } else
        return input;

}