List of usage examples for javax.servlet.jsp JspException JspException
public JspException(Throwable cause)
JspException
with the specified cause. From source file:com.glaf.core.tag.TagUtils.java
/** * Converts the scope name into its corresponding PageContext constant * value.//from ww w.j a va 2 s . c o m * * @param scopeName * Can be "page", "request", "session", or "application" in any * case. * @return The constant representing the scope (ie. * PageContext.REQUEST_SCOPE). * @throws JspException * if the scopeName is not a valid name. */ public int getScope(String scopeName) throws JspException { Integer scope = (Integer) scopes.get(scopeName.toLowerCase()); if (scope == null) { throw new JspException(messages.getMessage("lookup.scope", scope)); } return scope.intValue(); }
From source file:com.ultrapower.eoms.common.plugin.ecside.tag.TableTag.java
@Override public void doCatch(Throwable e) throws Throwable { throw new JspException("TableTag Problem: " + ExceptionUtils.formatStackTrace(e)); }
From source file:com.xhsoft.framework.common.page.MiniPageTag.java
/** * <p>Description:print info to jsp page</p> * @param request /*w ww . ja v a 2s .com*/ * @param mothod * @param page * @return void * @author wenzhi * @version 1.0 * @exception JspException */ private void printOutPages(HttpServletRequest request, String mothod, String page) throws JspException { if (mothod.endsWith("now")) { try { JspWriter out = pageContext.getOut(); String outString = " <span><font class='currentNum'>[" + page + "]</font></span>"; out.print(outString); } catch (Exception e) { throw new JspException(e); } } else { try { JspWriter out = pageContext.getOut(); String outString = " " + "<a href=\"javascript:setPage('" + page + "','" + targets + "');\">" + "" + page + "</a>"; out.print(outString); } catch (Exception e) { throw new JspException(e); } } }
From source file:com.ultrapower.eoms.common.plugin.ecside.tag.TableTag.java
@Override public int doEndTag() throws JspException { model.getTable().setAttribute(/* w ww . j a v a 2s. co m*/ TableConstants.EXTEND_ATTRIBUTES, getExtendAttributesAsString()); try { pageContext.getOut().println(model.getViewData()); } catch (Exception e) { // LogHandler.errorLog(logger, msg); throw new JspException("TableTag.doEndTag() Problem: " + ExceptionUtils.formatStackTrace(e)); }finally{ doFinally(); } return EVAL_PAGE; }
From source file:org.openmrs.web.taglib.OpenmrsMessageTag.java
/** * Resolve the specified message or code or text or tag body into a concrete message string. The returned message string should * be unescaped.//w w w .ja v a 2 s. c o m */ protected String resolveMessage() throws JspException { MessageSource messageSource = getMessageSource(); if (messageSource == null) { throw new JspTagException("No corresponding MessageSource to resolve message with found"); } // first, evaluate the specified MessageSourceResolvable, if any MessageSourceResolvable resolvedMessage = null; if (this.message instanceof MessageSourceResolvable) { resolvedMessage = (MessageSourceResolvable) this.message; } else if (this.message != null) { String expr = this.message.toString(); throw new JspException("Attribute value \"" + expr + "\" is neither a JSP EL expression nor " + "assignable to result class [" + MessageSourceResolvable.class.getName() + "]"); } if (resolvedMessage != null) { // we have a given MessageSourceResolvable. return messageSource.getMessage(resolvedMessage, getRequestContext().getLocale()); } String resolvedCode = this.code; String bodyText = null; String resolvedText = null; // if locale specified with tag attribute is the same as context locale if (OpenmrsUtil.nullSafeEquals(this.locale, Context.getLocale().getLanguage())) { // we need to evaluate fallback values in this case resolvedText = this.text; if (getBodyContent() != null) { bodyText = getBodyContent().getString(); } } // by default message code is used as fallback String message = resolvedCode; if (resolvedCode != null || resolvedText != null || bodyText != null) { // we have either a code or default text or body that we need to resolve. Object[] argumentsArray = resolveArguments(this.arguments); if (bodyText != null) { // we have a fallback body text to consider. message = messageSource.getMessage(resolvedCode, argumentsArray, bodyText, getRequestContext().getLocale()); } else if (resolvedText != null) { // we have a fallback value of text attribute to consider. message = messageSource.getMessage(resolvedCode, argumentsArray, resolvedText, getRequestContext().getLocale()); } else { // we have no fallback text to consider. try { message = messageSource.getMessage(resolvedCode, argumentsArray, getRequestContext().getLocale()); } catch (NoSuchMessageException e) { // do nothing, use resolved code as fallback } } } // all we have is a specified literal text. return message; }
From source file:com.germinus.easyconf.taglib.PropertyTag.java
private Object readProperty(ComponentProperties conf) throws JspException { Object value;//ww w . j a v a 2 s . c o m if (getType().equals("java.util.List")) { value = conf.getList(property, getPropertyFilter(), EMPTY_LIST); } else if (getType().equals("java.lang.Integer")) { value = conf.getInteger(property, getPropertyFilter(), new Integer(0)); } else if (getType().equals("java.lang.String[]")) { value = conf.getStringArray(property, getPropertyFilter(), new String[0]); } else if (getType().equals("java.lang.String")) { if (defaultValue != null) { value = conf.getString(property, getPropertyFilter(), defaultValue); } else { value = conf.getString(property, getPropertyFilter()); } } else if (getType().equals("java.lang.Double")) { value = new Double(conf.getDouble(property, getPropertyFilter())); } else if (getType().equals("java.lang.Float")) { value = new Float(conf.getFloat(property, getPropertyFilter())); } else if (getType().equals("java.lang.Byte")) { value = new Byte(conf.getByte(property, getPropertyFilter())); } else if (getType().equals("java.math.BigDecimal")) { value = conf.getBigDecimal(property, getPropertyFilter()); } else if (getType().equals("java.lang.BigInteger")) { value = conf.getBigInteger(property, getPropertyFilter()); } else if (getType().equals("java.lang.Boolean")) { value = new Boolean(conf.getBoolean(property, getPropertyFilter())); } else if (getType().equals("java.lang.Short")) { value = new Short(conf.getShort(property, getPropertyFilter())); } else if (getType().equals("java.lang.Long")) { value = new Long(conf.getLong(property, getPropertyFilter())); } else { JspException e = new JspException("Unsupported type: " + type); RequestUtils.saveException(pageContext, e); throw e; } return value; }
From source file:net.sf.ginp.tags.TreeMenu.java
/** * Description of the Method.//from w w w . j a va2 s . c om * *@param folders Description of the Parameter *@exception JspException Description of the Exception */ final void doFolders(final String[] folders) throws JspException { if (grid.size() > 0) { if (((GridElement) grid.get(grid.size() - 1)).getHtml().equals(gridend)) { ((GridElement) grid.get(grid.size() - 1)).setHtml(gridblank); } else { ((GridElement) grid.get(grid.size() - 1)).setHtml(gridcont); } } grid.add(new GridElement(gridtee)); try { for (int i = 0; i < folders.length; i++) { if (shownodes) { if (currentPath.equals(folders[i] + "/") && selectedFolder.equals(folders[i] + "/") && (ModelUtil.getFolderManager().getPicturesInDirectoryLength(model.getCollection(), folders[i]) > 0)) { gotMoreNodes = true; } } if (i == (folders.length - 1)) { if (shownodes) { if (gotMoreNodes && !selectedFolder.equals(folders[i] + "/")) { ((GridElement) grid.get(grid.size() - 1)).setHtml(gridtee); } else { ((GridElement) grid.get(grid.size() - 1)).setHtml(gridend); } } else { ((GridElement) grid.get(grid.size() - 1)).setHtml(gridend); } } // write out line pageContext.getOut().write(linestart); for (int j = 0; j < grid.size(); j++) { pageContext.getOut().write(((GridElement) grid.get(j)).getHtml()); } if (currentPath.startsWith(folders[i])) { pageContext.getOut().write(folderopen); } else { pageContext.getOut().write(folderclosed); } pageContext.getOut() .write("<a href=\"" + "ginpservlet?cmd=selectpath&path=" + folders[i] + "&colid=" + model.getCurrCollectionId() + "\"" + anchorextra + ">" + folders[i].substring(folders[i].lastIndexOf("/") + 1) + "</a>" + lineend); if (currentPath.startsWith(folders[i])) { doFolders(ModelUtil.getFolderManager().getFoldersInDirectory(model.getCollection(), folders[i] + "/")); if (shownodes) { if (selectedFolder.equals(folders[i] + "/")) { doNodes(folders[i]); } } // crop the current path if (currentPath.indexOf("/", 1) > 0) { currentPath = currentPath.substring(currentPath.indexOf("/", 1)); } } } } catch (IOException ioe) { log.error(ioe); throw new JspException(ioe.getMessage()); } grid.removeElementAt(grid.size() - 1); if (grid.size() > 0) { if (!((GridElement) grid.get(grid.size() - 1)).getHtml().equals(gridblank)) { ((GridElement) grid.get(grid.size() - 1)).setHtml(gridtee); } } }
From source file:net.naijatek.myalumni.util.taglib.BuildImageTag.java
/** * Process the end of this tag./* ww w . jav a 2s. c o m*/ * * @throws JspException * if a JSP exception has occurred * @return int */ @Override public final int doEndTag() throws JspException { request = (HttpServletRequest) pageContext.getRequest(); String uploadDir = BaseConstants.UPLOAD_DIR_NAME; String logoUploadDir = BaseConstants.LOGO_UPLOAD_DIR_NAME; String adsUploadDir = BaseConstants.ADS_UPLOAD_DIR_NAME; String avatarUploadDir = BaseConstants.AVATAR_UPLOAD_DIR_NAME; String seperator = "/"; String width_ad = app.getValue("image.width"); String width_avatar = app.getValue("avatar.image.width"); String height_avatar = app.getValue("avatar.image.height"); String name_of_avatar = app.getValue("avatar.image.name"); String rootContext = request.getContextPath(); StringBuffer sb = new StringBuffer(); if (imageType.equalsIgnoreCase(BaseConstants.TAGLIB_TYPE_ADVERTISEMENT)) { if (imageUrl.length() > 0) { sb.append("<img src=\"" + rootContext.trim() + seperator + uploadDir + seperator + adsUploadDir + seperator + imageUrl.trim() + "\" border=\"0\" width=\"" + width_ad + "\">"); } else { sb.append( "<img src=\"" + rootContext.trim() + seperator + "images" + seperator + "" + name_of_avatar + "" + "\" border=\"0\" width=\"150\" height=\"150\" align=\"ABSMIDDLE\">"); } // logger.debug("Advertisement url = " + sb.toString()); } else if (imageType.equalsIgnoreCase(BaseConstants.TAGLIB_TYPE_EDITABLE_AVATAR)) { if (imageUrl.length() > 0) { sb.append("<img src=\"" + rootContext.trim() + seperator + uploadDir + seperator + avatarUploadDir + seperator + imageUrl.trim() + "\" border=\"0\" width=\"" + width_avatar + "\" " + "height=\"" + height_avatar + "\" align=\"absmiddle\">"); } else { sb.append( "<img src=\"" + rootContext.trim() + seperator + "images" + seperator + "" + name_of_avatar + "" + "\" border=\"0\" width=\"150\" height=\"150\" align=\"absmiddle\">"); } } else if (imageType.equalsIgnoreCase(BaseConstants.TAGLIB_TYPE_LOGO)) { if (imageUrl.trim() != null && imageUrl.trim().length() > 0) { File f = new File(sysProp.getValue("LOGO.FILEPATH") + seperator + imageUrl.trim()); if (!f.isDirectory() && f.exists()) { sb.append("<img src=\"" + rootContext.trim() + seperator + uploadDir + seperator + logoUploadDir + seperator + imageUrl.trim() + "\" border=\"0\" align=\"absmiddle\" altKey=\"" + app.getValue("application.name") + "\" titleKey=\"" + app.getValue("application.name") + "\">"); } else { sb.append(app.getValue("error.logonotfound")); } } else { sb.append("<img src=\"" + rootContext.trim() + seperator + "images" + seperator + "logo" + seperator + "myalumni_03.png\" border=\"0\" align=\"absmiddle\" altKey=\"" + app.getValue("application.name") + "\" titleKey=\"" + app.getValue("application.name") + "\">"); } } else if (imageType.equalsIgnoreCase(BaseConstants.TAGLIB_TYPE_AVATAR)) { if (imageUrl.length() > 0) { sb.append("<img src=\"" + rootContext.trim() + seperator + uploadDir + seperator + avatarUploadDir + seperator + imageUrl.trim() + "\" border=\"0\" width=\"" + width_avatar + "\" " + "height=\"" + height_avatar + "\" align=\"absmiddle\">"); } else { sb.append( "<img src=\"" + rootContext.trim() + seperator + "images" + seperator + "" + name_of_avatar + "" + "\" border=\"0\" width=\"150\" height=\"150\" align=\"absmiddle\">"); } // logger.debug("Avatar url = " + sb.toString()); } else if (imageType.equalsIgnoreCase(BaseConstants.TAGLIB_TYPE_IMAGE)) { // Display // a // regular // image // int quotaRatio = 0 ; int quota = 0; try { quota = Integer.parseInt(imageUrl); } catch (NumberFormatException e) { quota = 0; } double imageWidth = ((quota * 100) / SystemConfigConstants.MAIL_QUOTA) / .3; double usedQuotaPercent = quota / (SystemConfigConstants.MAIL_QUOTA / 100); if (imageUrl.length() > 0) { if (usedQuotaPercent < 70) { sb.append("<img align=\"left\" width=\"" + imageWidth + "\" height=\"15\" src=\"" + rootContext.trim() + seperator + "images" + seperator + "icon" + seperator + "percent_low.gif" + "\" vspace=\"0\" hspace=\"0\" alt=\"Low Mail Percentage\"/>"); } else if (usedQuotaPercent <= 85) { sb.append("<img align=\"left\" width=\"" + imageWidth + "\" height=\"15\" src=\"" + rootContext.trim() + seperator + "images" + seperator + "icon" + seperator + "percent_med.gif" + "\" vspace=\"0\" hspace=\"0\" alt=\"Medium Mail Percentage\"/>"); } else { sb.append("<img align=\"left\" width=\"" + imageWidth + "\" height=\"15\" src=\"" + rootContext.trim() + seperator + "images" + seperator + "icon" + seperator + "percent_high.gif" + "\" vspace=\"0\" hspace=\"0\" alt=\"High Mail Percentage\"/>"); } } } try { pageContext.getOut().print(sb.toString()); } catch (Exception e) { logger.debug(e.getMessage()); throw new JspException("IO Problem in BuildImageTag " + e.getMessage()); } return EVAL_PAGE; }
From source file:com.redhat.rhn.frontend.taglibs.ListDisplayTag.java
/** * Set the name:value pair for the request attribute controlling display * of any optional buttons/*ww w. j a va 2 s .co m*/ * @param attrNameValue name/value pair separated by ":" * @throws JspException indicates attrNameValue is in the wrong format */ public void setButtonsAttr(String attrNameValue) throws JspException { String[] parts = attrNameValue.split(":"); if (parts.length != 2) { throw new JspException("buttonsAttr value must be of the form \"name:value\""); } buttonsAttrName = parts[0]; buttonsAttrValue = parts[1]; }
From source file:com.xhsoft.framework.common.page.MiniPageTag.java
/** * <p>Description:?</p>/* ww w . ja va 2s . co m*/ * @param pageNo * @param request * @return void * @author wenzhi * @version 1.0 * @exception JspException */ private void printOutFront(int pageNo, HttpServletRequest request) throws JspException { try { String first = ""; String prev = ""; JspWriter out = pageContext.getOut(); String outString = ""; if (pageNo == 1) { outString = "" + " " + first + " " + " " + prev + " "; } else { Integer prePage = new Integer(pageNo == 1 ? pageNo : pageNo - 1); outString = "" + "<a href=\"javascript:setPage('" + 1 + "','" + targets + "');\">" + first + " </a> " + "<a href=\"javascript:setPage('" + prePage + "','" + targets + "');\">" + prev + " </a> "; } out.print(outString); } catch (Exception e) { throw new JspException(e); } }