List of usage examples for javax.servlet.jsp JspException JspException
public JspException(Throwable cause)
JspException
with the specified cause. From source file:com.gisgraphy.webapp.taglib.ConstantsTag.java
/** * Main method that does processing and exposes Constants in specified scope * //from w ww. j a v a2s . com * @return int * @throws JspException * if processing fails */ @Override public int doStartTag() throws JspException { // Using reflection, get the available field names in the class Class<?> c = null; int toScope = PageContext.PAGE_SCOPE; if (scope != null) { toScope = getScope(scope); } try { c = Class.forName(clazz); } catch (ClassNotFoundException cnf) { log.error("ClassNotFound - maybe a typo?"); throw new JspException(cnf.getMessage()); } try { // if var is null, expose all variables if (var == null) { Field[] fields = c.getDeclaredFields(); AccessibleObject.setAccessible(fields, true); for (Field field : fields) { pageContext.setAttribute(field.getName(), field.get(this), toScope); } } else { try { Object value = c.getField(var).get(this); pageContext.setAttribute(c.getField(var).getName(), value, toScope); } catch (NoSuchFieldException nsf) { log.error(nsf.getMessage()); throw new JspException(nsf); } } } catch (IllegalAccessException iae) { log.error("Illegal Access Exception - maybe a classloader issue?"); throw new JspException(iae); } // Continue processing this page return (SKIP_BODY); }
From source file:net.sibcolombia.portal.web.tag.AlphabetLinkTag.java
void addLink(StringBuffer sb, String contextPath, char letter) throws JspException { sb.append("<a href=\""); sb.append(contextPath);// w w w. j a va 2s . c o m sb.append(rootUrl); if (logger.isDebugEnabled()) { logger.debug("Character to render:" + letter + ", unicode value:" + ((int) letter)); } try { String urlEncodedChar = URLEncoder.encode(String.valueOf(letter), "UTF-8"); if (!urlEncodedChar.equals(String.valueOf(letter))) { sb.append((int) letter); } else { sb.append(letter); } } catch (Exception e) { throw new JspException(e); } sb.append("\" class=\""); sb.append(linkClass); sb.append("\">"); sb.append(letter); sb.append("</a>"); }
From source file:net.mlw.vlh.web.util.JspUtils.java
/** * Write the specified text as the response to the writer associated with the * body content for the tag within which we are currently nested. * //from www. j av a 2 s . co m * @param pageContext * The PageContext object for this page * @param text * The text to be written * * @exception JspException * if an input/output error occurs */ public static void writePrevious(PageContext pageContext, String text) throws JspException { JspWriter writer = pageContext.getOut(); if (writer instanceof BodyContent) { writer = ((BodyContent) writer).getEnclosingWriter(); } try { writer.print(text); } catch (IOException e) { LOGGER.error("JspUtils.writePrevious() exception...", e); throw new JspException(e); } }
From source file:com.draagon.meta.web.tag.MetaIfValueTag.java
public int doStartTag() throws JspException { try {/* ww w . j av a2 s . c om*/ String id = getName(); String field = getField(); String value = getValue(); if (id == null) { log.error("(doStartTag) The 'name' attribute cannot be null!"); return SKIP_BODY; } if (field == null) { log.error("(doStartTag) The 'field' attribute cannot be null!"); return SKIP_BODY; } if (value == null) { log.error("(doStartTag) The 'value' attribute cannot be null!"); return SKIP_BODY; } boolean iff = false; if (getIf() == null || getIf().equals("true")) iff = true; Object o = pageContext.getRequest().getAttribute(id); if (o == null) return Tag.SKIP_BODY; // throw new JspException( "No object with id [" + id + "] was found" ); MetaObject mc = MetaDataLoader.findMetaObject(o); if (mc == null) { log.error("Cannot find MetaClass for object [" + o + "]"); return Tag.SKIP_BODY; } MetaField f = mc.getMetaField(field); if (f == null) { log.error("Cannot find MetaField for MetaClass [" + mc + "] with name [" + field + "]"); return Tag.SKIP_BODY; } boolean equals = false; // Just compare the strings to see if they are equal String ov = "" + f.getString(o); if (value.equals(ov)) equals = true; // Return the correct include if (equals && iff) return Tag.EVAL_BODY_INCLUDE; else if (!equals && !iff) return Tag.EVAL_BODY_INCLUDE; } catch (Exception e) { log.error("Error processing If Value Tag", e); throw new JspException("Error processing If Value Tag: " + e); } return Tag.SKIP_BODY; }
From source file:com.geemvc.taglib.form.LabelTagSupport.java
@Override protected void appendTagBody(JspWriter writer) throws JspException { StringWriter bodyWriter = null; try {//from w ww . j ava2 s . c o m if (jspBody != null && label == null) { bodyWriter = new StringWriter(); jspBody.invoke(bodyWriter); label = bodyWriter.toString(); } if (label == null) { label = messageResolver.resolve(name, requestContext(), true); } if (label != null) writer.write(label); } catch (Throwable t) { throw new JspException(t); } finally { IOUtils.closeQuietly(bodyWriter); } }
From source file:net.sf.ginp.tags.GetFolders.java
/** * called when the start tag is processed. * * @return Description of the Return Value * @exception JspException Description of the Exception *//*from www .j ava 2 s . c o m*/ public final int doStartTag() throws JspException { count = 0; try { model = ModelUtil.getModel((HttpServletRequest) pageContext.getRequest()); } catch (Exception e) { log.error(e); throw new JspException(e); } end = model.getCollection().getFoldersLength(); if (end > 0) { pageContext.setAttribute("link", "ginpservlet?cmd=selectpath&path=" + model.getCollection().getFolder(count) + "&colid=" + model.getCurrCollectionId()); pageContext.setAttribute("name", (model.getCollection().getFolder(count)) .substring((model.getCollection().getFolder(count)).lastIndexOf("/") + 1)); return EVAL_BODY_AGAIN; } else { return SKIP_BODY; } }
From source file:net.sourceforge.fenixedu.presentationTier.TagLib.content.ContentLinkTag.java
@Override public int doEndTag() throws JspException { try {/* w w w . ja v a 2s. com*/ writeStartTag(); if (getHrefInBody() != null && getHrefInBody()) { final Site content = getContent(name, pageContext, getScope(), getProperty()); write(content.getFullPath()); } else { write(getBodyContent().getString().trim()); } writeEndTag(); } catch (IOException e) { throw new JspException(e); } this.release(); return EVAL_PAGE; }
From source file:com.trailmagic.image.ui.ImageGroupLinkTag.java
public int doStartTag() throws JspException { StringBuffer html = new StringBuffer(); try {//from ww w.ja va2 s . co m html.append("<a "); if (m_styleClass != null) { html.append("class=\"" + m_styleClass + "\" "); } html.append("href=\""); //XXX: yeek? WebApplicationContext ctx = WebApplicationContextUtils .getRequiredWebApplicationContext(pageContext.getServletContext()); LinkHelper helper = ctx.getBean(LinkHelper.class); HttpServletRequest request = (HttpServletRequest) pageContext.getRequest(); if (m_image != null) { html.append(helper.getImageGroupFrameUrl(request, m_imageGroup, m_image)); } else if (m_imageGroup != null) { html.append(helper.getImageGroupUrl(request, m_imageGroup)); } else if (m_owner != null) { html.append(helper.getImageGroupsUrl(request, m_groupType, m_owner)); } else { html.append(helper.getImageGroupsRootUrl(request, m_groupType)); } html.append("\">"); pageContext.getOut().write(html.toString()); return EVAL_BODY_INCLUDE; } catch (IOException e) { throw new JspException(e); } }
From source file:net.jcreate.e3.table.html.tag.ColumnTag.java
public int doStartTag() throws JspException { this.setBodyContent(null); TableTag tableTag = getTableTag();/*from w w w.j a va2 s . c o m*/ if (tableTag == null) { throw new JspException("column table?"); } boolean isCreatedTable = tableTag.isCreatedTable(); if (isCreatedTable == false) { tableTag.addColumnProperty(this.property); //property tableTag.addColumnBeanProperty(this.beanProperty == null ? this.property : this.beanProperty); return SKIP_BODY; } boolean isCreatedHeader = tableTag.isCreatedHeader(); if (isCreatedHeader == false) { return SKIP_BODY; } HTMLRow currRow = tableTag.getCurrRow(); if (currRow == null) { return super.doStartTag(); } currCell = (HTMLCell) currRow.getCell(this.property); currCell.setCellDecorator(new CompositeCellDecorator()); return EVAL_BODY_BUFFERED; }
From source file:com.steeleforge.aem.ironsites.wcm.taglib.SetModeTag.java
@Override public int doEndTag() throws JspException { try {// ww w .j a va 2 s .com if (null != this.wcmmode) { this.wcmmode.toRequest(WCMUtil.getSlingRequest(pageContext)); } } catch (RuntimeException re) { LOG.debug(re.getMessage()); throw new JspException(re); } return EVAL_PAGE; }