Search in sources :

Example 11 with JspTagException

use of javax.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) {
            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));
    }
}
Also used : NoSuchMessageException(org.springframework.context.NoSuchMessageException) IOException(java.io.IOException) JspTagException(javax.servlet.jsp.JspTagException)

Example 12 with JspTagException

use of javax.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 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

JspTagException (javax.servlet.jsp.JspTagException)12 IOException (java.io.IOException)8 JspException (javax.servlet.jsp.JspException)2 InputStream (java.io.InputStream)1 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 SimpleDateFormat (java.text.SimpleDateFormat)1 Date (java.util.Date)1 Locale (java.util.Locale)1 RequestDispatcher (javax.servlet.RequestDispatcher)1 ServletException (javax.servlet.ServletException)1 JspWriter (javax.servlet.jsp.JspWriter)1 BodyContent (javax.servlet.jsp.tagext.BodyContent)1 SlingHttpServletRequest (org.apache.sling.api.SlingHttpServletRequest)1 SlingHttpServletResponse (org.apache.sling.api.SlingHttpServletResponse)1 RequestDispatcherOptions (org.apache.sling.api.request.RequestDispatcherOptions)1 Resource (org.apache.sling.api.resource.Resource)1 SyntheticResource (org.apache.sling.api.resource.SyntheticResource)1 JspSlingHttpServletResponseWrapper (org.apache.sling.scripting.jsp.util.JspSlingHttpServletResponseWrapper)1 NoSuchMessageException (org.springframework.context.NoSuchMessageException)1 BindStatus (org.springframework.web.servlet.support.BindStatus)1