Example usage for javax.servlet.jsp JspTagException JspTagException

List of usage examples for javax.servlet.jsp JspTagException JspTagException

Introduction

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

Prototype

public JspTagException(String message, Throwable rootCause) 

Source Link

Document

Constructs a new JspTagException when the JSP Tag needs to throw an exception and include a message about the "root cause" exception that interfered with its normal operation, including a description message.

Usage

From source file:org.jsecurity.web.tags.PrincipalTag.java

@SuppressWarnings({ "unchecked" })
public int onDoStartTag() throws JspException {
    String strValue = null;//from w  ww .  ja va2  s . c o  m

    if (getSubject() != null) {

        // Get the principal to print out
        Object principal;

        if (type == null) {
            principal = getSubject().getPrincipal();
        } else {
            principal = getPrincipalFromClassName();
        }

        // Get the string value of the principal
        if (principal != null) {
            if (property == null) {
                strValue = principal.toString();
            } else {
                strValue = getPrincipalProperty(principal, property);
            }
        }

    }

    // Print out the principal value if not null
    if (strValue != null) {
        try {
            pageContext.getOut().write(strValue);
        } catch (IOException e) {
            throw new JspTagException("Error writing [" + strValue + "] to JSP.", e);
        }
    }

    return SKIP_BODY;
}

From source file:org.openmrs.module.web.taglib.ExtensionPointTag.java

/**
 * @see javax.servlet.jsp.tagext.Tag#doEndTag()
 *//*from w  w w  . j  a va2  s  .  c o  m*/
public int doEndTag() throws JspException {
    try {
        if (getBodyContent() != null) {
            if (log.isDebugEnabled()) {
                log.debug("Ending tag: " + bodyContent.getString());
            }
            if (extensions != null) {
                getBodyContent().writeOut(bodyContent.getEnclosingWriter());
            }
            bodyContent.clearBody();
        } else {
            // the tag doesn't have a body, so initBody and doAfterBody have
            // not been called. Do iterations now
            while (extensions != null && extensions.hasNext()) {
                Extension ext = extensions.next();
                ext.initialize(parameterMap);
                String overrideContent = ext.getOverrideContent("");
                if (overrideContent != null) {
                    pageContext.getOut().write(overrideContent);
                }
            }
        }
    } catch (java.io.IOException e) {
        throw new JspTagException("IO Error while ending tag for point: " + pointId, e);
    }
    release();
    return EVAL_PAGE;
}