List of usage examples for javax.servlet.jsp JspException JspException
public JspException(Throwable cause)
JspException
with the specified cause. From source file:it.eng.spagobi.commons.presentation.tags.ListTag.java
protected boolean verifyConditions(SourceBean conditionsSB, SourceBean row) throws JspException { boolean conditionVerified = true; if (conditionsSB != null) { List conditions = conditionsSB.getAttributeAsList("PARAMETER"); if (conditions != null && conditions.size() > 0) { for (int j = 0; j < conditions.size(); j++) { SourceBean condition = (SourceBean) conditions.get(j); String parameterName = (String) condition.getAttribute("NAME"); String parameterScope = (String) condition.getAttribute("SCOPE"); String parameterValue = (String) condition.getAttribute("VALUE"); String functionality = (String) condition.getAttribute("user_functionality"); String inParameterValue = null; Object parameterValueObject = null; if (functionality != null && !functionality.equalsIgnoreCase("")) { try { if (!profile.isAbleToExecuteAction(functionality)) { conditionVerified = false; break; } else { continue; }/*from ww w . ja v a 2 s. co m*/ } catch (EMFInternalError e) { e.printStackTrace(); logger.error(e); } } if (parameterScope != null && parameterScope.equalsIgnoreCase("LOCAL")) { if (row == null) { logger.error("Impossible to associate LOCAL scope: the row is null"); throw new JspException("Impossible to associate LOCAL scope: the row is null"); } // if (row == null) parameterValueObject = row.getAttribute(parameterName); } else { parameterValueObject = ContextScooping.getScopedParameter(_requestContainer, _responseContainer, parameterName, parameterScope); } if (parameterValueObject != null) inParameterValue = parameterValueObject.toString(); if (parameterValue.equalsIgnoreCase("AF_DEFINED")) { if (inParameterValue == null) { conditionVerified = false; break; } // if (inParameterValue == null) continue; } // if (parameterValue.equalsIgnoreCase("AF_DEFINED")) if (parameterValue.equalsIgnoreCase("AF_NOT_DEFINED")) { if (inParameterValue != null) { conditionVerified = false; break; } // if (inParameterValue != null) continue; } // if (parameterValue.equalsIgnoreCase("AF_NOT_DEFINED")) String operator = (String) condition.getAttribute("OPERATOR"); if (operator == null || operator.trim().equals("")) operator = "EQUAL_TO"; else operator = operator.trim(); if (operator.equalsIgnoreCase("EQUAL_TO")) { if (!(parameterValue.equalsIgnoreCase(inParameterValue))) { conditionVerified = false; break; } // if (!(parameterValue.equalsIgnoreCase(inParameterValue))) } // if (operator.equalsIgnoreCase("EQUAL_TO")) if (operator.equalsIgnoreCase("GREATER_THAN")) { double parameterValueDouble = Double.parseDouble(parameterValue); double inParameterValueDouble = Double.parseDouble(inParameterValue); if (!(inParameterValueDouble > parameterValueDouble)) { conditionVerified = false; break; } // if (!(inParameterValueDouble > parameterValueDouble)) } // if (operator.equalsIgnoreCase("GREATER_THAN")) if (operator.equalsIgnoreCase("GREATER_OR_EQUAL_THAN")) { double parameterValueDouble = Double.parseDouble(parameterValue); double inParameterValueDouble = Double.parseDouble(inParameterValue); if (!(inParameterValueDouble >= parameterValueDouble)) { conditionVerified = false; break; } // if (!(inParameterValueDouble >= parameterValueDouble)) } // if (operator.equalsIgnoreCase("GREATER_OR_EQUAL_THAN")) if (operator.equalsIgnoreCase("LESS_THAN")) { double parameterValueDouble = Double.parseDouble(parameterValue); double inParameterValueDouble = Double.parseDouble(inParameterValue); if (!(inParameterValueDouble > parameterValueDouble)) { conditionVerified = false; break; } // if (!(inParameterValueDouble < parameterValueDouble)) } // if (operator.equalsIgnoreCase("LESS_THAN")) if (operator.equalsIgnoreCase("LESS_OR_EQUAL_THAN")) { double parameterValueDouble = Double.parseDouble(parameterValue); double inParameterValueDouble = Double.parseDouble(inParameterValue); if (!(inParameterValueDouble <= parameterValueDouble)) { conditionVerified = false; break; } // if (!(inParameterValueDouble <= parameterValueDouble)) } // if (operator.equalsIgnoreCase("LESS_OR_EQUAL_THAN")) } } } return conditionVerified; }
From source file:jp.terasoluna.fw.web.struts.taglib.PageLinksTag.java
/** * ?IuWFNgintp?B//from w ww .j ava 2s . com * * @param obj intIuWFNg * @return l * @throws JspException JSPO */ protected int getInt(Object obj) throws JspException { int retInt = 0; String value = ObjectUtils.toString(obj); if (!"".equals(value)) { try { retInt = Integer.parseInt(value); } catch (NumberFormatException e) { log.error(e.getMessage()); throw new JspException(e); } } return retInt; }
From source file:it.eng.spagobi.commons.presentation.tags.ListTag.java
/** * Gets all parameter information from a module, putting them into a HashMap. * //from w w w . j a va2 s. com * @param parameters The parameters list * @param row The value objects Source Bean * @return The parameters Hash Map * @throws JspException If any Exception occurred */ protected HashMap getParametersMap(List parameters, SourceBean row) throws JspException { HashMap params = new HashMap(); for (int i = 0; i < parameters.size(); i++) { String name = (String) ((SourceBean) parameters.get(i)).getAttribute("NAME"); String type = (String) ((SourceBean) parameters.get(i)).getAttribute("TYPE"); String value = (String) ((SourceBean) parameters.get(i)).getAttribute("VALUE"); String scope = (String) ((SourceBean) parameters.get(i)).getAttribute("SCOPE"); if (name != null) { //name = JavaScript.escape(name.toUpperCase()); name = name.toUpperCase(); if ((type != null) && type.equalsIgnoreCase("RELATIVE")) { if ((scope != null) && scope.equalsIgnoreCase("LOCAL")) { if (row == null) { logger.error("Impossible to associate local scope to the button"); throw new JspException("Impossible to associate local scope to the button"); } // if (row == null) Object valueObject = row.getAttribute(value); if (valueObject != null) value = valueObject.toString(); else value = ""; } // if ((scope != null) && scope.equalsIgnoreCase("LOCAL")) else value = (String) (ContextScooping.getScopedParameter(_requestContainer, _responseContainer, value, scope)).toString(); } // if ((type != null) && type.equalsIgnoreCase("RELATIVE")) if (value == null) value = ""; //value = JavaScript.escape(value); } // if (name != null) params.put(name, value); } // for (int i = 0; i < parameters.size(); i++) return params; }
From source file:net.testdriven.psiprobe.jsp.DurationTag.java
@Override public int doStartTag() throws JspException { try {//from w ww . j ava2 s . c om pageContext.getOut().write(duration(value)); } catch (IOException e) { logger.debug("Exception writing duration to JspWriter", e); throw new JspException(e); } return EVAL_BODY_INCLUDE; }
From source file:net.testdriven.psiprobe.jsp.VisualScoreTag.java
@Override public int doAfterBody() throws JspException { if (value < minValue) { log.info("value " + value + " is less than min value " + minValue); value = minValue;/*from w ww . j a va2 s .c om*/ } if (value > maxValue) { log.info("value " + value + " is greater than max value " + maxValue); value = maxValue; } if (value + value2 < minValue || value2 < 0) { log.info("value2 " + value2 + " is less than min value"); value2 = 0; } if (value + value2 > maxValue) { log.info("value2 " + value2 + " is greater than max value"); value2 = maxValue - value; } double unitSize = (maxValue - minValue) / (fullBlocks * partialBlocks); double blockWidth = unitSize * partialBlocks; int fullRedBlockCount = (int) Math.floor(value / blockWidth); int partialRedBlockIndex = (int) Math.floor((value - fullRedBlockCount * blockWidth) / unitSize); int partialBlueBlockIndex1 = (partialRedBlockIndex > 0 ? Math.min((int) Math.floor(value2 / unitSize), partialBlocks - partialRedBlockIndex) : 0); int fullBlueBlockCount = Math.max(0, (int) Math.floor(value2 / blockWidth) - (partialRedBlockIndex > 0 ? 1 : 0)); int partialBlueBlockIndex2 = (int) Math.floor( (value2 - (fullBlueBlockCount * blockWidth) - (partialBlueBlockIndex1 * unitSize)) / unitSize); BodyContent bc = getBodyContent(); String body = bc.getString().trim(); StringBuilder buf = new StringBuilder(); // Beginning if (showA) { String format = "a0"; if (fullRedBlockCount > 0 || partialRedBlockIndex > 0) { format = "a1"; } else if (partialBlueBlockIndex1 == 0 && (fullBlueBlockCount > 0 || partialBlueBlockIndex2 > 0)) { format = "a2"; } buf.append(MessageFormat.format(body, new Object[] { format })); } // Full red blocks String fullRedBody = MessageFormat.format(body, partialBlocks + "+0"); for (int i = 0; i < fullRedBlockCount; i++) { buf.append(fullRedBody); } // Mixed red/blue block (mid-block transition) if (partialRedBlockIndex > 0) { String partialBody = MessageFormat.format(body, partialRedBlockIndex + "+" + partialBlueBlockIndex1); buf.append(partialBody); } // Full blue blocks String fullBlueBody = MessageFormat.format(body, "0+" + partialBlocks); for (int i = 0; i < fullBlueBlockCount; i++) { buf.append(fullBlueBody); } // Partial blue block if (partialBlueBlockIndex2 > 0) { String partialBody = MessageFormat.format(body, "0+" + partialBlueBlockIndex2); buf.append(partialBody); } // Empty blocks int emptyBlocks = showEmptyBlocks ? fullBlocks - (fullRedBlockCount + fullBlueBlockCount + (partialRedBlockIndex > 0 ? 1 : 0) + (partialBlueBlockIndex2 > 0 ? 1 : 0)) : 0; if (emptyBlocks > 0) { String emptyBody = MessageFormat.format(body, "0+0"); for (int i = 0; i < emptyBlocks; i++) { buf.append(emptyBody); } } // End if (showB) { String format = "b0"; if (fullRedBlockCount == fullBlocks) { format = "b1"; } else if (fullRedBlockCount + (partialRedBlockIndex + partialBlueBlockIndex1 == partialBlocks ? 1 : 0) + fullBlueBlockCount == fullBlocks) { format = "b2"; } buf.append(MessageFormat.format(body, new Object[] { format })); } try { JspWriter out = bc.getEnclosingWriter(); out.print(buf.toString()); } catch (IOException ioe) { throw new JspException("Error:IOException while writing to client" + ioe.getMessage()); } return SKIP_BODY; }
From source file:net.testdriven.psiprobe.jsp.VolumeTag.java
@Override public int doStartTag() throws JspException { String title = Long.toString(value); String newValue = SizeExpression.format(value, fractions, true); try {/*from w ww. j av a 2 s . co m*/ pageContext.getOut().write("<span title=\"" + title + "\">" + newValue + "</span>"); } catch (IOException e) { logger.debug("Exception writing value to JspWriter", e); throw new JspException(e); } return EVAL_BODY_INCLUDE; }
From source file:net.ymate.framework.core.taglib.AbstractTagSupport.java
@Override public int doEndTag() throws JspException { if (__iterator != null) { try {/*from w w w . jav a 2 s .c o m*/ if (this.getBodyContent() != null) { pageContext.getOut().write(this.getBodyContent().getString()); this.getBodyContent().clearBody(); } } catch (IOException e) { throw new JspException(RuntimeUtils.unwrapThrow(e)); } } return super.doEndTag(); }
From source file:net.ymate.framework.core.taglib.CodecTag.java
@Override protected Object doProcessTagData() throws JspException { String _result = null;//from w ww . j a v a 2 s .c om try { if ("base64encode".equalsIgnoreCase(method)) { _result = Base64.encodeBase64String(data.getBytes(StringUtils.defaultIfEmpty(charset, "UTF-8"))); } else if ("base64decode".equalsIgnoreCase(method)) { _result = new String(Base64.decodeBase64(data), StringUtils.defaultIfEmpty(charset, "UTF-8")); } else { _result = DigestUtils.md5Hex(data); } } catch (UnsupportedEncodingException e) { throw new JspException(RuntimeUtils.unwrapThrow(e)); } return _result; }
From source file:net.ymate.framework.core.taglib.ElementsTag.java
@Override public int doEndTag() throws JspException { try {/*ww w. j a v a2 s .co m*/ StringBuilder _tagContent = __doTagStart(); if (this.getBodyContent() != null) { __doTagContent(_tagContent, new StringBuilder(this.getBodyContent().getString())); this.getBodyContent().clearBody(); } else { __doTagContent(_tagContent, new StringBuilder(0)); } if (_tagContent != null && _tagContent.length() > 0) { pageContext.getOut().write(_tagContent.toString()); } } catch (IOException e) { throw new JspException(RuntimeUtils.unwrapThrow(e)); } this._id = null; this._class = null; this._style = null; this._tag = null; this._unclosed = false; this.__dynamicAttributes.clear(); return super.doEndTag(); }
From source file:net.ymate.framework.core.taglib.ui.CssTag.java
@Override public int doStartTag() throws JspException { __ui = (BaseUITag) this.getParent(); if (__ui == null) { throw new JspException("Parent UITag or LayoutTag not found."); }/*w w w . ja v a 2s . c o m*/ return super.doStartTag(); }