List of usage examples for javax.servlet.jsp JspException JspException
public JspException(Throwable cause)
JspException
with the specified cause. From source file:org.shredzone.cilla.web.tag.MetaTag.java
@Override public int doEndTag() throws JspException { String value = content;//from ww w . ja v a 2s. c om if (value == null) { value = getBodyContent().getString(); } org.shredzone.cilla.web.header.tag.MetaTag meta = new org.shredzone.cilla.web.header.tag.MetaTag(name, value, scheme); DocumentHeader header = documentHeaderManager.getDocumentHeader(); if (!replace && header.contains(meta)) { throw new JspException("Meta " + name + " is already set"); } header.add(meta); return EVAL_PAGE; }
From source file:mercury.tags.SetInitialLocale.java
@Override public void doTag() throws JspException { try {/*from ww w.j a v a2 s .c o m*/ PageContext pageContext = (PageContext) getJspContext(); if (pageContext.getServletContext().getAttribute("FIRST_EXECUTION") != null) { pageContext.getServletContext().removeAttribute("FIRST_EXECUTION"); pageContext.getSession().removeAttribute("LAST_VISITED_PAGE"); pageContext.getSession().removeAttribute("MESSAGE_TEXT"); pageContext.getSession().removeAttribute("MESSAGE_LEVEL"); pageContext.getSession().setAttribute("MESSAGE_TEXT", "DIALOG_VOID"); pageContext.getSession().setAttribute("MESSAGE_LEVEL", "NORMAL"); } String lastVisitedPage = (String) pageContext.getSession().getAttribute("LAST_VISITED_PAGE"); if (lastVisitedPage == null || lastVisitedPage.trim().equals("")) { lastVisitedPage = errorJsp; pageContext.getSession().setAttribute("LAST_VISITED_PAGE", lastVisitedPage); } if ((String) pageContext.getSession().getAttribute("I18N") == null) { String locale = pageContext.getRequest().getLocale().toString(); Properties languages = (Properties) pageContext.getServletContext().getAttribute("LANGUAGES"); if (StringUtils.isNotBlank(locale) && languages.containsKey(locale)) { pageContext.getSession().setAttribute("I18N", locale); } else { pageContext.getSession().setAttribute("I18N", defaultLanguage); } } } catch (Exception ex) { log.error(ex.getMessage(), ex); throw new JspException("[mercury.SetInitialLocale.doTag()] Exception: " + ex.getMessage()); } }
From source file:gov.nih.nci.ncicb.cadsr.common.jsp.tag.handler.SecureIconDisplay.java
public int doStartTag() throws javax.servlet.jsp.JspException { HttpServletRequest req;/* w w w .j a v a 2s .co m*/ JspWriter out; try { Form form = null; if (formScope.equals(CaDSRConstants.SESSION_SCOPE)) { form = (Form) pageContext.getSession().getAttribute(formId); } else if (formScope.equals(CaDSRConstants.PAGE_SCOPE)) { form = (Form) pageContext.getAttribute(formId); } if (form == null) throw new JspException("Secure icon: no form object in any scope "); Context userContext = form.getContext(); NCIUser nciUser = (NCIUser) pageContext.getSession().getAttribute(USER_KEY); req = (HttpServletRequest) pageContext.getRequest(); out = pageContext.getOut(); //// GF29128 D.An, 20130729. String un = (String) req.getSession().getAttribute("myUsername"); if (un == null) un = "viewer"; ////System.out.println( request.getSession().getAttribute("myUsername") ); String targetStr = ""; if (target != null) targetStr = "target=\"" + target + "\" "; if (hasPrivilege(role, formType, nciUser, form) //// GF29128 D.An, 20130729. && !un.equals("viewer")) { String hrefVal = null; if (confirmMessageKey != null) hrefVal = getConfirmMethod(getHrefUrl(req, form)); else hrefVal = getHrefUrl(req, form); out.print("<a href=\"" + hrefVal + "\" " + targetStr + "/><img src=\"" + urlPrefix + activeImageSource + "\" border=0 alt='" + altMessage + "'></a>"); } else { if (inactiveImageSource != null) out.print("<img src=\"" + urlPrefix + inactiveImageSource + "\"border=0>"); } } catch (IOException ioe) { throw new JspException("I/O Error : " + ioe.getMessage()); } //end try/catch return Tag.SKIP_BODY; }
From source file:net.sf.ginp.tags.GetPicture.java
/** * Called when a Start tag is processed. * *@return Description of the Return Value *@exception JspException Description of the Exception *//* ww w.j a v a2 s . c o m*/ public final int doStartTag() throws JspException { try { model = ModelUtil.getModel((HttpServletRequest) pageContext.getRequest()); } catch (Exception e) { log.error("Error getting Model.", e); throw new JspException(e); } String picHeight = (model.getPageHeight() - bordervertical) + ""; String picName = ((HttpServletRequest) pageContext.getRequest()).getParameter("name"); if (picName == null) { log.error("Error: picName == null"); return SKIP_BODY; } else if (picName.equals("null")) { log.error("Error: picName.equals(\"null\")"); return SKIP_BODY; } else { Picture pic = new Picture(model.getCollection().getRoot() + model.getCollection().getPath(), picName); // Set Picture Attributes pageContext.setAttribute("filename", pic.getFileName()); pageContext.setAttribute("date", pic.getDate(dateformatpattern, model.getLocale())); pageContext.setAttribute("time", pic.getTime()); pageContext.setAttribute("title", pic.getTitle()); pageContext.setAttribute("description", pic.getDescription(model.getLocale())); if (((HttpServletRequest) pageContext.getRequest()).getParameter("height") == null) { if (height > 0) { picHeight = height + ""; } } else { try { int height = (new Integer( ((HttpServletRequest) pageContext.getRequest()).getParameter("height")).intValue()) - bordervertical; if (height > 0) { picHeight = "" + height; } } catch (Exception e) { log.error("Error with picture height.", e); picHeight = (model.getPageHeight() - bordervertical) + ""; } } pageContext.setAttribute("src", ((HttpServletRequest) pageContext.getRequest()).getContextPath() + "/ginppic?path=" + model.getCollection().getPath() + "&name=" + picName + "&height=" + picHeight); if (model.getCollection().getNextPictureName(picName) != null) { pageContext.setAttribute("link", "ginpservlet?cmd=showpicture&colid=" + model.getCurrCollectionId() + "&path=" + model.getCollection().getPath() + "&name=" + model.getCollection().getNextPictureName(picName)); } else { pageContext.setAttribute("link", "ginpservlet?cmd=selectpath&path=" + model.getCollection().getPath() + "&colid=" + model.getCurrCollectionId()); } return EVAL_BODY_INCLUDE; } }
From source file:com.vityuk.ginger.servlet.tags.MessageTag.java
@Override public int doStartTag() throws JspException { ServletRequest servletRequest = pageContext.getRequest(); ServletContext servletContext = pageContext.getServletContext(); Localization localization = getLocalization(servletRequest, servletContext); boolean escapeHtml = resolveEscapeHtml(servletContext); Object[] parameters = resolveParameters(); final String message; if (selector != null) { message = localization.getSelectedMessage(code, selector, parameters); } else if (count >= 0) { message = localization.getPluralMessage(code, count, parameters); } else {//from w w w . j ava 2 s .com message = localization.getMessage(code, parameters); } String messageOut = escapeHtml ? StringEscapeUtils.escapeHtml4(message) : message; try { pageContext.getOut().write(String.valueOf(messageOut)); } catch (IOException e) { throw new JspException(e); } return SKIP_BODY; }
From source file:com.steeleforge.aem.ironsites.wcm.taglib.ModeHelperTag.java
public int doEndTag() throws JspException { try {/* w ww. j a v a 2s . com*/ init(); setupModeMap(); setupModeObject(); } catch (Exception e) { LOG.error(e.getMessage()); throw new JspException(e); } return EVAL_PAGE; }
From source file:gov.nih.nci.ncicb.cadsr.common.jsp.tag.handler.AltQuestionText.java
public int doStartTag() throws javax.servlet.jsp.JspException { HttpServletRequest req;/*from ww w.ja va 2 s. c o m*/ JspWriter out; try { req = (HttpServletRequest) pageContext.getRequest(); out = pageContext.getOut(); Question currQuestion = (Question) pageContext.getAttribute(questionBeanId); String longName = currQuestion.getLongName(); DataElement de = currQuestion.getDataElement(); if (questionProperty != null && orgModuleBeanId != null) { // Get the property from the Question in the orgModule // If its a new Question the get the property value from // the DataElement for deProperty if deProperty is defined Module orgModule = (Module) pageContext.getSession().getAttribute(orgModuleBeanId); if (orgModule == null) throw new JspException("No Bean by name " + orgModuleBeanId + "in session"); List orgQuestions = orgModule.getQuestions(); String propValue = null; if (orgQuestions.contains(currQuestion)) { Question orgQuestion = getQuestionFromList(currQuestion.getQuesIdseq(), orgQuestions); propValue = (String) PropertyUtils.getProperty(orgQuestion, questionProperty); } else// get the value from the de { if (deProperty != null) { if (de != null) propValue = (String) PropertyUtils.getProperty(de, deProperty); } } /*if(propValue==null) return Tag.SKIP_BODY; */ /* for saved question, use the default question text when CDE does not have preferred question text This is a temporary fix for GF1437 - to keep saved question behavior consistent for CDE with/without Preferred Question Text */ if ((propValue == null || propValue.length() == 0) && "longCDEName".equals(deProperty) && "longName".equals(questionProperty)) { propValue = "Data Element " + de.getLongName() + " does not have Preferred Question Text"; } String script = generateJavaScript("question", formIndex, questionIndex, questionProperty, propValue); StringBuffer linkStr = new StringBuffer( "<a href=\"javascript:question" + questionIndex + questionProperty + "populate()\">"); linkStr.append(propValue); linkStr.append("</a>"); out.print(script); out.print(linkStr.toString()); } else if (de != null) { String propValue = (String) PropertyUtils.getProperty(de, deProperty); /*if(propValue==null) return Tag.SKIP_BODY; */ /* for saved question, use the default question text when CDE does not have preferred question text This is a temporary fix for GF1437 - to keep saved question behavior consistent for CDE with/without Preferred Question Text */ if (propValue == null && "longCDEName".equals(deProperty) && "longName".equals(questionProperty)) { propValue = "Data Element " + de.getLongName() + " does not have Preferred Question Text"; } if (propValue.equals(longName)) { out.print(propValue); } else { String script = generateJavaScript("questionde", formIndex, questionIndex, deProperty, propValue); StringBuffer linkStr = new StringBuffer( "<a href=\"javascript:questionde" + questionIndex + deProperty + "populate()\">"); linkStr.append(propValue); linkStr.append("</a>"); out.print(script); out.print(linkStr.toString()); } } //out.print(getTableFooter()); } catch (Exception ioe) { throw new JspException("I/O Error : " + ioe.getMessage()); } //end try/catch return Tag.SKIP_BODY; }
From source file:net.sf.ginp.tags.GetCollectionTitle.java
/** * called when the start tag is processed. * *@return Description of the Return Value *@exception JspException Description of the Exception *//*from ww w. j a v a 2s . c om*/ public final int doStartTag() throws JspException { GinpModel model; try { model = ModelUtil.getModel((HttpServletRequest) pageContext.getRequest()); } catch (Exception e) { log.error(e); throw new JspException(e); } if ((model.getCurrCollectionId() == -1) || (model.getCollection() == null)) { return SKIP_BODY; } PicCollection collection = model.getCollection(); sbPath = new StringBuffer(); count = 1; pageContext.setAttribute("link", "ginpservlet?cmd=selectcollection&id=" + model.getCurrCollectionId()); pageContext.setAttribute("name", collection.getName()); colid = model.getCurrCollectionId(); pathFolders = StringTool.splitToArray(collection.getPath().substring(0, collection.getPath().length() - 1), "/"); return EVAL_BODY_INCLUDE; }
From source file:net.mlw.vlh.web.tag.AddParamTag.java
/** * @throws NoSuchMethodException// w w w .ja va 2 s. co m * @throws InvocationTargetException * @throws IllegalAccessException * @see javax.servlet.jsp.tagext.Tag#doStartTag() */ public int doStartTag() throws JspException { ParamAddable parent = (ParamAddable) JspUtils.getParent(this, ParamAddable.class); if ((property != null) && (value != null)) { final String message = "For one parameter" + name + "you can not use two values (first dynamic from the property, 2nd static from the value"; LOGGER.error(message); throw new JspException(message); } if (name == null) { // use the same name as the name of property, if name is not // specified name = property; } if (property != null) { DefaultRowTag rowTag = (DefaultRowTag) JspUtils.getParent(this, DefaultRowTag.class); Object bean = pageContext.getAttribute(rowTag.getBeanName()); if (bean != null && !(bean instanceof Spacer)) { try { value = String.valueOf(PropertyUtils.getProperty(bean, property)); } catch (Exception e) { LOGGER.error("<vlh:addParam> Error getting property '" + property + "'."); value = null; } } else { if (LOGGER.isDebugEnabled()) { LOGGER.debug("Row's JavaBean '" + rowTag.getBeanName() + "' is null or Valuelist is empty!"); } value = null; } } if (value == null) { if (LOGGER.isInfoEnabled()) { LOGGER.info( "The param '" + addActionParamPrefix(name) + "' is skiped, because it's value is null!"); } } else { parent.addParam(addActionParamPrefix(name), value); if (LOGGER.isDebugEnabled()) { LOGGER.debug( "The param '" + addActionParamPrefix(name) + "' was added with the value '" + value + "'."); } } release(); return SKIP_BODY; }
From source file:com.alibaba.jstorm.ui.tags.CpuTag.java
@Override public void doTag() throws JspException { JspWriter out = getJspContext().getOut(); try {/* w ww .j av a 2 s. co m*/ if (!StringUtils.isBlank(ratio)) { double value = JStormUtils.parseDouble(ratio); double danger_threshold = workers * 100; double warn_threshold = danger_threshold * THRESHOLD; String status_success = "success"; String status_warning = "warning"; String status_danger = "danger"; StringBuilder sb = new StringBuilder(); sb.append("<div class='progress cpu-ratio-bar'>"); if (Double.compare(value, warn_threshold) <= 0) { double width = value / danger_threshold * 100; appendBar(sb, width, value, status_success); } else if (Double.compare(value, danger_threshold) <= 0) { double width1 = THRESHOLD * 100; double width2 = (value - warn_threshold) / danger_threshold * 100; appendBar(sb, width1, value, status_success); appendBar(sb, width2, value, status_warning); } else { double width1 = danger_threshold / value * 100; double width2 = 100 - width1; appendBar(sb, width1, value, status_success); appendBar(sb, width2, value, status_danger); } sb.append("</div>"); out.write(sb.toString()); } } catch (IOException e) { throw new JspException("Error: " + e.getMessage()); } }