Search in sources :

Example 96 with JspException

use of javax.servlet.jsp.JspException in project jodd by oblac.

the class DefaultTag method doTag.

@Override
public void doTag() throws JspException {
    JspTag parent = getParent();
    if (!(parent instanceof SwitchTag)) {
        throw new JspException(SwitchTag.MSG_PARENT_SWITCH_REQUIRED, null);
    }
    SwitchTag switchTag = (SwitchTag) parent;
    if (!switchTag.isValueFounded()) {
        TagUtil.invokeBody(getJspBody());
    }
}
Also used : JspException(javax.servlet.jsp.JspException) JspTag(javax.servlet.jsp.tagext.JspTag)

Example 97 with JspException

use of javax.servlet.jsp.JspException in project jodd by oblac.

the class IteratorTag method doTag.

@Override
public void doTag() throws JspException {
    if (items == null) {
        return;
    }
    JspFragment body = getJspBody();
    if (body == null) {
        return;
    }
    PageContext pageContext = (PageContext) getJspContext();
    // create an iterator status if the status attribute was set.
    if (status != null) {
        iteratorStatus = new IteratorStatus(this.modulus);
        TagUtil.setScopeAttribute(status, iteratorStatus, scope, pageContext);
    }
    if (items instanceof Collection) {
        iterateCollection((Collection) items, from, count, pageContext);
    } else if (items.getClass().isArray()) {
        iterateArray((Object[]) items, from, count, pageContext);
    } else if (items instanceof String) {
        iterateArray(Convert.toStringArray(items), from, count, pageContext);
    } else {
        throw new JspException("Provided items are not iterable");
    }
    // cleanup
    if (status != null) {
        TagUtil.removeScopeAttribute(status, scope, pageContext);
    }
    TagUtil.removeScopeAttribute(var, scope, pageContext);
}
Also used : JspFragment(javax.servlet.jsp.tagext.JspFragment) JspException(javax.servlet.jsp.JspException) Collection(java.util.Collection) PageContext(javax.servlet.jsp.PageContext)

Example 98 with JspException

use of javax.servlet.jsp.JspException in project jodd by oblac.

the class ThenTag method doTag.

@Override
public void doTag() throws JspException {
    JspTag parent = getParent();
    if (!(parent instanceof IfElseTag)) {
        throw new JspException("Parent IfElse tag is required", null);
    }
    IfElseTag ifTag = (IfElseTag) parent;
    if (ifTag.getTestValue()) {
        TagUtil.invokeBody(getJspBody());
    }
}
Also used : JspException(javax.servlet.jsp.JspException) JspTag(javax.servlet.jsp.tagext.JspTag)

Example 99 with JspException

use of javax.servlet.jsp.JspException in project spring-framework by spring-projects.

the class EvalTag method doEndTag.

@Override
public int doEndTag() throws JspException {
    EvaluationContext evaluationContext = (EvaluationContext) this.pageContext.getAttribute(EVALUATION_CONTEXT_PAGE_ATTRIBUTE);
    if (evaluationContext == null) {
        evaluationContext = createEvaluationContext(this.pageContext);
        this.pageContext.setAttribute(EVALUATION_CONTEXT_PAGE_ATTRIBUTE, evaluationContext);
    }
    if (this.var != null) {
        Object result = this.expression.getValue(evaluationContext);
        this.pageContext.setAttribute(this.var, result, this.scope);
    } else {
        try {
            String result = this.expression.getValue(evaluationContext, String.class);
            result = ObjectUtils.getDisplayString(result);
            result = htmlEscape(result);
            result = (this.javaScriptEscape ? JavaScriptUtils.javaScriptEscape(result) : result);
            this.pageContext.getOut().print(result);
        } catch (IOException ex) {
            throw new JspException(ex);
        }
    }
    return EVAL_PAGE;
}
Also used : JspException(javax.servlet.jsp.JspException) EvaluationContext(org.springframework.expression.EvaluationContext) StandardEvaluationContext(org.springframework.expression.spel.support.StandardEvaluationContext) IOException(java.io.IOException)

Example 100 with JspException

use of javax.servlet.jsp.JspException in project spring-framework by spring-projects.

the class RequestContextAwareTag method doStartTag.

/**
	 * Create and expose the current RequestContext.
	 * Delegates to {@link #doStartTagInternal()} for actual work.
	 * @see #REQUEST_CONTEXT_PAGE_ATTRIBUTE
	 * @see org.springframework.web.servlet.support.JspAwareRequestContext
	 */
@Override
public final int doStartTag() throws JspException {
    try {
        this.requestContext = (RequestContext) this.pageContext.getAttribute(REQUEST_CONTEXT_PAGE_ATTRIBUTE);
        if (this.requestContext == null) {
            this.requestContext = new JspAwareRequestContext(this.pageContext);
            this.pageContext.setAttribute(REQUEST_CONTEXT_PAGE_ATTRIBUTE, this.requestContext);
        }
        return doStartTagInternal();
    } catch (JspException ex) {
        logger.error(ex.getMessage(), ex);
        throw ex;
    } catch (RuntimeException ex) {
        logger.error(ex.getMessage(), ex);
        throw ex;
    } catch (Exception ex) {
        logger.error(ex.getMessage(), ex);
        throw new JspTagException(ex.getMessage());
    }
}
Also used : JspException(javax.servlet.jsp.JspException) JspAwareRequestContext(org.springframework.web.servlet.support.JspAwareRequestContext) JspTagException(javax.servlet.jsp.JspTagException) JspException(javax.servlet.jsp.JspException) JspTagException(javax.servlet.jsp.JspTagException)

Aggregations

JspException (javax.servlet.jsp.JspException)158 IOException (java.io.IOException)34 Map (java.util.Map)30 HashMap (java.util.HashMap)21 HttpServletRequest (javax.servlet.http.HttpServletRequest)21 JspWriter (javax.servlet.jsp.JspWriter)21 Iterator (java.util.Iterator)20 ActionMessages (org.apache.struts.action.ActionMessages)15 MockFormBean (org.apache.struts.mock.MockFormBean)15 InvocationTargetException (java.lang.reflect.InvocationTargetException)11 ActionMessage (org.apache.struts.action.ActionMessage)11 ArrayList (java.util.ArrayList)7 Collection (java.util.Collection)7 List (java.util.List)7 Locale (java.util.Locale)6 PageExpiredException (org.mifos.framework.exceptions.PageExpiredException)6 MalformedURLException (java.net.MalformedURLException)5 ModuleConfig (org.apache.struts.config.ModuleConfig)5 UserContext (org.mifos.security.util.UserContext)5 SimpleDateFormat (java.text.SimpleDateFormat)4