use of jakarta.servlet.jsp.JspTagException in project tomcat by apache.
the class FooTag method doAfterBody.
@Override
public int doAfterBody() throws JspException {
try {
if (i == 3) {
bodyOut.writeOut(bodyOut.getEnclosingWriter());
return SKIP_BODY;
}
pageContext.setAttribute("member", atts[i]);
i++;
return EVAL_BODY_BUFFERED;
} catch (IOException ex) {
throw new JspTagException(ex.toString());
}
}
use of jakarta.servlet.jsp.JspTagException in project tomcat by apache.
the class LogTag method doAfterBody.
@Override
public int doAfterBody() throws JspException {
try {
String s = bodyOut.getString();
System.err.println(s);
if (toBrowser) {
bodyOut.writeOut(bodyOut.getEnclosingWriter());
}
return SKIP_BODY;
} catch (IOException ex) {
throw new JspTagException(ex.toString());
}
}
use of jakarta.servlet.jsp.JspTagException 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 | RuntimeException ex) {
logger.error(ex.getMessage(), ex);
throw ex;
} catch (Exception ex) {
logger.error(ex.getMessage(), ex);
throw new JspTagException(ex.getMessage());
}
}
use of jakarta.servlet.jsp.JspTagException in project spring-framework by spring-projects.
the class BindTag method doStartTagInternal.
@Override
protected final int doStartTagInternal() throws Exception {
String resolvedPath = getPath();
if (!isIgnoreNestedPath()) {
String nestedPath = (String) this.pageContext.getAttribute(NestedPathTag.NESTED_PATH_VARIABLE_NAME, PageContext.REQUEST_SCOPE);
// only prepend if not already an absolute path
if (nestedPath != null && !resolvedPath.startsWith(nestedPath) && !resolvedPath.equals(nestedPath.substring(0, nestedPath.length() - 1))) {
resolvedPath = nestedPath + resolvedPath;
}
}
try {
this.status = new BindStatus(getRequestContext(), resolvedPath, isHtmlEscape());
} catch (IllegalStateException ex) {
throw new JspTagException(ex.getMessage());
}
// Save previous status values, for re-exposure at the end of this tag.
this.previousPageStatus = this.pageContext.getAttribute(STATUS_VARIABLE_NAME, PageContext.PAGE_SCOPE);
this.previousRequestStatus = this.pageContext.getAttribute(STATUS_VARIABLE_NAME, PageContext.REQUEST_SCOPE);
// Expose this tag's status object as PageContext attribute,
// making it available for JSP EL.
this.pageContext.removeAttribute(STATUS_VARIABLE_NAME, PageContext.PAGE_SCOPE);
this.pageContext.setAttribute(STATUS_VARIABLE_NAME, this.status, PageContext.REQUEST_SCOPE);
return EVAL_BODY_INCLUDE;
}
use of jakarta.servlet.jsp.JspTagException in project spring-framework by spring-projects.
the class MessageTag method doEndTag.
/**
* Resolves the message, escapes it if demanded,
* and writes it to the page (or exposes it as variable).
* @see #resolveMessage()
* @see org.springframework.web.util.HtmlUtils#htmlEscape(String)
* @see org.springframework.web.util.JavaScriptUtils#javaScriptEscape(String)
* @see #writeMessage(String)
*/
@Override
public int doEndTag() throws JspException {
try {
// Resolve the unescaped message.
String msg = resolveMessage();
// HTML and/or JavaScript escape, if demanded.
msg = htmlEscape(msg);
msg = this.javaScriptEscape ? JavaScriptUtils.javaScriptEscape(msg) : msg;
// Expose as variable, if demanded, else write to the page.
if (this.var != null) {
this.pageContext.setAttribute(this.var, msg, TagUtils.getScope(this.scope));
} else {
writeMessage(msg);
}
return EVAL_PAGE;
} catch (IOException ex) {
throw new JspTagException(ex.getMessage(), ex);
} catch (NoSuchMessageException ex) {
throw new JspTagException(getNoSuchMessageExceptionDescription(ex));
}
}
Aggregations