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