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());
}
}
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);
}
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());
}
}
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;
}
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());
}
}
Aggregations