Search in sources :

Example 76 with JspException

use of javax.servlet.jsp.JspException in project bamboobsc by billchen198318.

the class SelectTag method doEndTag.

@Override
public int doEndTag() throws JspException {
    Select select = this.handler();
    try {
        this.pageContext.getOut().write(select.getHtml());
        this.pageContext.getOut().write(select.getScript());
    } catch (IOException e) {
        e.printStackTrace();
    } catch (Exception e) {
        e.printStackTrace();
    }
    select = null;
    return 0;
}
Also used : Select(org.gsweb.components.ui.Select) IOException(java.io.IOException) JspException(javax.servlet.jsp.JspException) IOException(java.io.IOException)

Example 77 with JspException

use of javax.servlet.jsp.JspException in project HongsCORE by ihongs.

the class NuidTag method doTag.

@Override
public void doTag() throws JspException {
    JspWriter out = getJspContext().getOut();
    String uid;
    if (this.sid != null) {
        uid = Core.newIdentity(this.sid);
    } else {
        uid = Core.newIdentity();
    }
    try {
        out.print(uid);
        JspFragment f = getJspBody();
        if (f != null)
            f.invoke(out);
    } catch (java.io.IOException ex) {
        throw new JspException("Error in NuidTag", ex);
    }
}
Also used : JspFragment(javax.servlet.jsp.tagext.JspFragment) JspException(javax.servlet.jsp.JspException) JspWriter(javax.servlet.jsp.JspWriter)

Example 78 with JspException

use of javax.servlet.jsp.JspException in project Lucee by lucee.

the class FormatTag method doEndTag.

/**
 * Method called at end of Tag
 *
 * @return EVAL_PAGE
 */
@Override
public final int doEndTag() throws JspException {
    String date_formatted = default_text;
    if (output_date != null) {
        // Get the pattern to use
        SimpleDateFormat sdf;
        String pat = pattern;
        if (pat == null && patternid != null) {
            Object attr = pageContext.findAttribute(patternid);
            if (attr != null)
                pat = attr.toString();
        }
        if (pat == null) {
            sdf = new SimpleDateFormat();
            pat = sdf.toPattern();
        }
        // Get a DateFormatSymbols
        if (symbolsRef != null) {
            symbols = (DateFormatSymbols) pageContext.findAttribute(symbolsRef);
            if (symbols == null) {
                throw new JspException("datetime format tag could not find dateFormatSymbols for symbolsRef \"" + symbolsRef + "\".");
            }
        }
        // Get a SimpleDateFormat using locale if necessary
        if (localeRef != null) {
            Locale locale = (Locale) pageContext.findAttribute(localeRef);
            if (locale == null) {
                throw new JspException("datetime format tag could not find locale for localeRef \"" + localeRef + "\".");
            }
            sdf = new SimpleDateFormat(pat, locale);
        } else if (locale_flag) {
            sdf = new SimpleDateFormat(pat, pageContext.getRequest().getLocale());
        } else if (symbols != null) {
            sdf = new SimpleDateFormat(pat, symbols);
        } else {
            sdf = new SimpleDateFormat(pat);
        }
        // See if there is a timeZone
        if (timeZone_string != null) {
            TimeZone timeZone = (TimeZone) pageContext.getAttribute(timeZone_string, PageContext.SESSION_SCOPE);
            if (timeZone == null) {
                throw new JspTagException("Datetime format tag timeZone " + "script variable \"" + timeZone_string + " \" does not exist");
            }
            sdf.setTimeZone(timeZone);
        }
        // Format the date for display
        date_formatted = sdf.format(output_date);
    }
    try {
        pageContext.getOut().write(date_formatted);
    } catch (Exception e) {
        throw new JspException("IO Error: " + e.getMessage());
    }
    return EVAL_PAGE;
}
Also used : Locale(java.util.Locale) JspException(javax.servlet.jsp.JspException) TimeZone(java.util.TimeZone) SimpleDateFormat(java.text.SimpleDateFormat) JspTagException(javax.servlet.jsp.JspTagException) JspException(javax.servlet.jsp.JspException) JspTagException(javax.servlet.jsp.JspTagException)

Example 79 with JspException

use of javax.servlet.jsp.JspException in project Payara by payara.

the class CacheTag method doAfterBody.

/**
 * doAfterBody is called only if the body was evaluated. This would happen
 * if nocache is specified in which case this should do nothing
 * if there was no cached response in which case the response data
 * is obtained from the bodyContent and cached
 * if the response has expired in which case the cache is refreshed
 *
 * @throws JspException the standard exception thrown
 * @return always returns SKIP_BODY since we dont do any iteration
 */
public int doAfterBody() throws JspException {
    // sent out, nothing more to be done.
    if (_useCachedResponse) {
        if (bodyContent != null) {
            // get the response as a string from bodyContent
            // and cache it for the specified timeout period
            String content = bodyContent.getString().trim();
            CacheEntry entry = new CacheEntry(content, _timeout);
            _cache.put(_key, entry);
            // write to body content to the enclosing writer as well
            try {
                bodyContent.writeOut(bodyContent.getEnclosingWriter());
            } catch (java.io.IOException ex) {
                throw new JspException(ex);
            }
        }
    }
    return SKIP_BODY;
}
Also used : JspException(javax.servlet.jsp.JspException)

Example 80 with JspException

use of javax.servlet.jsp.JspException in project opennms by OpenNMS.

the class ExpressionEvaluatorManager method getEvaluatorByName.

/**
 * Gets an ExpressionEvaluator from the cache, or seeds the cache
 * if we haven't seen a particular ExpressionEvaluator before.
 */
public static ExpressionEvaluator getEvaluatorByName(String name) throws JspException {
    Object oEvaluator = nameMap.get(name);
    if (oEvaluator != null) {
        return ((ExpressionEvaluator) oEvaluator);
    }
    try {
        synchronized (nameMap) {
            oEvaluator = nameMap.get(name);
            if (oEvaluator != null) {
                return ((ExpressionEvaluator) oEvaluator);
            }
            ExpressionEvaluator e = (ExpressionEvaluator) Class.forName(name).newInstance();
            nameMap.put(name, e);
            return (e);
        }
    } catch (ClassCastException ex) {
        // just to display a better error message
        throw new JspException("invalid ExpressionEvaluator: " + ex.toString(), ex);
    } catch (ClassNotFoundException ex) {
        throw new JspException("couldn't find ExpressionEvaluator: " + ex.toString(), ex);
    } catch (IllegalAccessException ex) {
        throw new JspException("couldn't access ExpressionEvaluator: " + ex.toString(), ex);
    } catch (InstantiationException ex) {
        throw new JspException("couldn't instantiate ExpressionEvaluator: " + ex.toString(), ex);
    }
}
Also used : JspException(javax.servlet.jsp.JspException)

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