List of usage examples for javax.servlet.jsp JspTagException JspTagException
public JspTagException(Throwable rootCause)
From source file:org.openmrs.web.taglib.ForEachDisplayAttributeTag.java
@Override protected Object next() throws JspTagException { if (attrTypes == null) { throw new JspTagException("The attr iterator is null"); }/*from w w w .ja v a 2 s . c om*/ return attrTypes.next(); }
From source file:org.openmrs.web.taglib.DisplayChartTag.java
/** * @see javax.servlet.jsp.tagext.Tag#doEndTag() *//*from w w w . jav a2s .com*/ public int doEndTag() throws JspException { try { if (bodyContent != null) { bodyContent.writeOut(bodyContent.getEnclosingWriter()); } } catch (java.io.IOException e) { throw new JspTagException("IO Error: " + e.getMessage()); } return EVAL_PAGE; }
From source file:net.sourceforge.subsonic.taglib.UrlTag.java
public int doEndTag() throws JspException { // Rewrite and encode the url. String result = formatUrl();//from w w w.j a v a 2 s . c o m // Store or print the output if (var != null) pageContext.setAttribute(var, result, PageContext.PAGE_SCOPE); else { try { pageContext.getOut().print(result); } catch (IOException x) { throw new JspTagException(x); } } return EVAL_PAGE; }
From source file:org.jahia.taglibs.query.SortByTag.java
@Override public int doEndTag() throws JspException { try {/* w w w . ja v a 2 s . c om*/ PropertyValue value = getQOMFactory().propertyValue(getSelectorName(), propertyName); getQOMBuilder().getOrderings() .add(StringUtils.equalsIgnoreCase("desc", order) ? getQOMFactory().descending(value) : getQOMFactory().ascending(value)); } catch (RepositoryException e) { throw new JspTagException(e); } finally { resetState(); } return EVAL_PAGE; }
From source file:org.infoglue.calendar.taglib.SlotsTag.java
/** * /* w w w . ja v a2 s . c o m*/ */ private void calculateSlots() throws JspException { try { if (elements != null && visibleElementsId != null) { Slots slots = new Slots(elements, currentSlot, slotSize, slotCount); setResultAttribute(visibleElementsId, slots.getVisibleElements()); setResultAttribute(visibleSlotsId, slots.getVisibleSlots()); setResultAttribute(lastSlotId, slots.getLastSlot()); } else if (maxSlots > 0) { Slots slots = new Slots(currentSlot, slotSize, slotCount, maxSlots); setResultAttribute(visibleSlotsId, slots.getVisibleSlots()); setResultAttribute(lastSlotId, slots.getLastSlot()); } else throw new JspTagException("Either elements/visibleElementsId or maxSlots must be specified."); } catch (Exception e) { log.error("Error calculating slots:" + e.getMessage()); throw new JspTagException(e.getMessage()); } }
From source file:com.sun.j2ee.blueprints.taglibs.smart.ClientStateTag.java
public int doEndTag() throws JspTagException { if (imageURL == null && buttonText == null) { throw new JspTagException( "ClientStateTag error: either an " + "imageURL or buttonText attribute must be specified."); }//from w w w.j a v a2 s . c om HttpServletRequest request = (HttpServletRequest) pageContext.getRequest(); StringBuffer buffer = new StringBuffer(); buffer.append("<form method=\"POST\" action=\"" + targetURL + "\">"); // insert any parameters that may have been added via sub tags if (parameters != null) { Iterator it = parameters.keySet().iterator(); // put the request attributes stored in the session in the request while (it.hasNext()) { String key = (String) it.next(); String value = (String) parameters.get(key); buffer.append(" <input type=\"hidden\" name=\"" + key + "\" value=\"" + value + "\" />"); } } String fullURL = request.getRequestURI(); // find the url that sent us this page String targetURL = null; int lastPathSeparator = fullURL.lastIndexOf("/") + 1; if (lastPathSeparator != -1) { targetURL = fullURL.substring(lastPathSeparator, fullURL.length()); } buffer.append(" <input type=\"hidden\" name=\"referring_URL\"" + "value=\"" + targetURL + "\">"); String referringScreen = (String) request.getSession().getAttribute(WebKeys.PREVIOUS_SCREEN); buffer.append(" <input type=\"hidden\" name=\"referring_screen\"" + "value=\"" + referringScreen + "\">"); buffer.append(" <input type=\"hidden\" name=\"cacheId\"" + "value=\"" + cacheId + "\">"); // check the request for previous parameters Map params = (Map) request.getParameterMap(); if (!params.isEmpty() && encodeRequestParameters) { Iterator it = params.entrySet().iterator(); // copy in the request parameters stored while (it.hasNext()) { Entry entry = (Entry) it.next(); String key = (String) entry.getKey(); if (!key.startsWith(cacheId)) { String[] values = (String[]) entry.getValue(); String valueString = values[0]; buffer.append(" <input type=\"hidden\" name=\"" + key + "\" value=\"" + valueString + "\" />"); } } } /** * Now serialize the request attributes into the page (only sealizable objects are going * to be processed). */ if (encodeRequestAttributes) { // put the request attributes into tattributres Enumeration enumeration = request.getAttributeNames(); while (enumeration.hasMoreElements()) { String key = (String) enumeration.nextElement(); // check if we have already serialized the items // also don't serialize javax items because if (!key.startsWith(cacheId) && !key.startsWith("javax.servlet")) { Object value = request.getAttribute(key); if (serializableClass == null) { try { serializableClass = Class.forName("java.io.Serializable"); } catch (java.lang.ClassNotFoundException cnf) { logger.error("ClientStateTag caught: ", cnf); } } // check if seralizable if (serializableClass.isAssignableFrom(value.getClass())) { try { ByteArrayOutputStream bos = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(bos); out.writeObject(value); out.close(); buffer.append(" <input type=\"hidden\" name=\"" + cacheId + "_attribute_" + key + "\" value=\"" + new String(Base64.encode(bos.toByteArray()), "ISO-8859-1") + "\" />"); } catch (java.io.IOException iox) { logger.error("ClientStateTag caught: ", iox); } } else { logger.info(key + " not to Serializeable"); } } } } // end get attributes // now put the link in if (imageURL != null) { buffer.append(" <input alt=\"" + altText + "\" type=\"image\" " + "src=\"" + imageURL + "\"/>"); } else { buffer.append(" <input alt=\"" + altText + "\" type=\"submit\" " + "value=\"" + buttonText + "\"/>"); } buffer.append("</form>"); // write the output to the output stream try { JspWriter out = pageContext.getOut(); out.print(buffer.toString()); } catch (IOException ioe) { logger.error("ClientStateTag: Problems with writing...", ioe); } // reset everything parameters = null; altText = ""; buttonText = null; imageURL = null; cacheId = null; targetURL = null; encodeRequestAttributes = true; encodeRequestParameters = true; serializableClass = null; return EVAL_PAGE; }
From source file:ch.entwine.weblounge.taglib.content.ActionTag.java
/** * Sets the module identifier. This method throws an exception if no module * with the given identifier can be found. * /* w ww . j a v a2 s. co m*/ * @param module * The module to set. */ public void setModule(String module) throws JspTagException { Site site = request.getSite(); this.module = site.getModule(module); if (this.module == null) { String msg = "Module '" + module + "' not found!"; throw new JspTagException(msg); } }
From source file:org.springframework.web.servlet.tags.RequestContextAwareTag.java
/** * Create and expose the current RequestContext. * Delegates to {@link #doStartTagInternal()} for actual work. * @see #REQUEST_CONTEXT_PAGE_ATTRIBUTE/* w w w.ja v a 2s. co m*/ * @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()); } }
From source file:org.jahia.taglibs.utility.constants.JahiaUseConstantsTag.java
private Map<?, ?> getConstants() throws JspTagException { Map<?, ?> constants = null; try {/*w ww . jav a 2 s . c o m*/ constants = ClassUtils.getClassConstants(getClassName()); } catch (ClassNotFoundException e) { throw new JspTagException("Class not found: " + getClassName()); } catch (IllegalArgumentException e) { throw new JspTagException("Illegal argument: " + getClassName()); } catch (IllegalAccessException e) { throw new JspTagException("Illegal access: " + getClassName()); } // make the map keys case-insensitive and the map unmodifiable return UnmodifiableMap.decorate(new CaseInsensitiveMap(constants)); }
From source file:org.openmrs.web.taglib.OpenmrsRequestContextAwareBodyTag.java
/** * After tag body has been evaluated and buffered this creates and exposes the current RequestContext. Delegates to * {@link #doEndTagInternal()} for actual work. *///from w w w.ja v a2s. c o m @Override public final int doEndTag() throws JspException { try { // get request content available from pageContext this.requestContext = (RequestContext) this.pageContext .getAttribute(RequestContextAwareTag.REQUEST_CONTEXT_PAGE_ATTRIBUTE); // if request context is not specified, create empty request context and set it into pageContext if (this.requestContext == null) { this.requestContext = new JspAwareRequestContext(this.pageContext); this.pageContext.setAttribute(RequestContextAwareTag.REQUEST_CONTEXT_PAGE_ATTRIBUTE, this.requestContext); } // do actual work of this tag return doEndTagInternal(); } 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()); } }