Example usage for javax.servlet.jsp JspException JspException

List of usage examples for javax.servlet.jsp JspException JspException

Introduction

In this page you can find the example usage for javax.servlet.jsp JspException JspException.

Prototype

public JspException(Throwable cause) 

Source Link

Document

Constructs a new JspException with the specified cause.

Usage

From source file:org.jamwiki.taglib.WatchlistTag.java

/**
 *
 *//*w w w .java2s . c  o  m*/
public int doEndTag() throws JspException {
    try {
        String tagValue = evaluateTag();
        HttpServletRequest request = (HttpServletRequest) this.pageContext.getRequest();
        String virtualWiki = WikiUtil.getVirtualWikiFromRequest(request);
        Watchlist watchlist = WikiUtil.currentWatchlist(request, virtualWiki);
        if (watchlist.containsTopic(tagValue)) {
            this.pageContext.getOut().print("</strong>");
        }
    } catch (Exception e) {
        logger.severe("Failure processing watchlist item " + this.topic, e);
        throw new JspException(e);
    }
    return EVAL_PAGE;
}

From source file:gov.nih.nci.cabig.caaers.web.tags.csm.CSMAccessControlTag.java

@Override
protected int doStartTagInternal() throws Exception {

    if (StringUtils.isBlank(authorizationCheckName) && StringUtils.isBlank(objectPrivilege)) {
        throw new JspException("Either 'authorizationCheckName' or 'objectPrivilege' are required");
    }//from  w w w.j  a  va2s.c om

    //evaluate the domain object
    Object resolvedDomainObject = null;
    if (domainObject instanceof String) {
        resolvedDomainObject = ExpressionEvaluationUtils.evaluate("domainObject", (String) domainObject,
                Object.class, pageContext);
    } else {
        resolvedDomainObject = domainObject;
    }

    //evaluate the privileges
    String evaledPrivilegesString = "";
    if (!StringUtils.isEmpty(hasPrivileges)) {
        evaledPrivilegesString = ExpressionEvaluationUtils.evaluateString("hasPrivileges", hasPrivileges,
                pageContext);
    }
    String[] requiredPrivileges = evaledPrivilegesString.split(",");

    boolean authFlag = false;
    if (StringUtils.isNotBlank(authorizationCheckName)) {
        authFlag = checkAuthorization(resolvedDomainObject, requiredPrivileges);
    } else {
        authFlag = checkAuthorization(objectPrivilege);
    }

    setVariable(authFlag);

    if (authFlag) {
        logger.debug("Authorization succeeded, evaluating body");
        return Tag.EVAL_BODY_INCLUDE;
    }

    logger.debug("No permission, so skipping tag body");
    return Tag.SKIP_BODY;

}

From source file:com.ultrapower.eoms.common.plugin.ecside.tag.MappingTag.java

 @Override
public int doStartTag() throws JspException {
     try {/* w w w.j  a  v  a2  s  . c om*/
            
        Object propertyValue = getValue();

           
         if (propertyValue != null) {
            propertyValue = ExpressionEvaluatorManager.evaluate("result", propertyValue.toString(), Object.class, this, pageContext);
         }

         if (mappingItem!=null ){
            Object mappingMap=pageContext.findAttribute((String)mappingItem);
               
             Object outValue=null;
             if (mappingMap instanceof Map){
                Map itemsMap=(Map)mappingMap;
                outValue=itemsMap.get(propertyValue);
                if (outValue==null && mappingDefaultKey!=null){
                   outValue=itemsMap.get(mappingDefaultKey);
                }
             }
             if (outValue==null){
                outValue=mappingDefaultValue;
             }
             propertyValue=outValue;
         }
            
         JspWriter w = pageContext.getOut();
         if (propertyValue == null || (propertyValue != null && propertyValue instanceof String && StringUtils.isBlank((String)propertyValue))) {
            w.write("");
         }else{
            w.write((String)propertyValue);
         }
            

            
                
     } catch (Exception e) {
         throw new JspException("MappingTag.doStartTag() Problem: " + ExceptionUtils.formatStackTrace(e));
     }

     return SKIP_BODY;
 }

From source file:com.wxxr.nirvana.jsp.taglib.ContainerTagSupport.java

/**
 * By default, all ContainerTags evaluate their body. Subclasses may choose
 * to be more selective. In any case, children can rely upon the container
 * and uiContext being initialized if they call
 * <code>super.doStartTag()</code>
 *
 * @return <code>EVAL_BODY_BUFFERED</code>.
 * @throws JspException/*from   w w w.  j a v a  2  s  .  c o  m*/
 *             If the container has not been initialized.
 */
public int doStartTag() throws JspException {
    container = ContainerAccess.getContainer();
    if (container != null) {
        startContext(pageContext);
        return EVAL_BODY_BUFFERED;
    } else {
        throw new JspException("TilesContainer not initialized");
    }
}

From source file:com.redhat.rhn.frontend.taglibs.RequiredFieldTag.java

/**
 * {@inheritDoc}//from   w w  w.  j  a  v  a  2 s.c  om
 */
public int doEndTag() throws JspException {
    JspWriter writer = pageContext.getOut();
    //<span class="required-form-field">*</span>
    HtmlTag span = new HtmlTag("span");
    span.setAttribute("class", REQUIRED_FIELD_CSS);
    span.addBody("*");
    try {
        writer.write(span.render());
        if (!StringUtils.isBlank(key)) {
            LocalizationService ls = LocalizationService.getInstance();
            String msg = ls.getMessage(key);
            if (msg.endsWith(":")) {
                writer.write(":");
            }
        }

    } catch (IOException e) {
        throw new JspException(e);
    }
    return SKIP_BODY;
}

From source file:net.sf.ginp.tags.GetCollectionTitles.java

/**
 *  Called when a Start tag is processed.
 *
 *@return                   Description of the Return Value
 *@exception  JspException  Description of the Exception
 */// w  ww  .  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(e);
        throw new JspException(e);
    }

    count = 0;
    end = model.getCollections().length;

    pageContext.setAttribute("link", "ginpservlet?cmd=selectcollection&id=" + count);
    pageContext.setAttribute("name", model.getCollection(count).getName());
    count = 1;

    return EVAL_BODY_INCLUDE;
}

From source file:de.micromata.genome.gwiki.web.tags.GWikiHtmlOptionsCollectionTag.java

@Override
public int doStartTag() throws JspException {
    GWikiHtmlSelectTag selTag = (GWikiHtmlSelectTag) pageContext
            .getAttribute(GWikiHtmlSelectTag.GWikiHtmlSelectTag_KEY);
    if (selTag == null) {
        throw new JspException("cann use optionsCollection only inside a select tag");
    }/*from   w  ww  . ja  v  a  2s.c  om*/
    Object collection = GWikiTagRenderUtils.readFormValue(pageContext, property);
    if (collection == null) {
        throw new JspException("Jsp: form." + property + " is a null value");
    }

    Iterator<?> iter = getIterator(collection);

    StringBuilder sb = new StringBuilder();

    while (iter.hasNext()) {

        Object bean = iter.next();
        Object beanLabel = null;
        Object beanValue = null;

        // Get the label for this option
        try {
            beanLabel = PropertyUtils.getProperty(bean, label);
            if (beanLabel == null) {
                beanLabel = "";
            }
        } catch (Exception ex) {
            throw new JspException("Cannot access label ' " + label + " from collection form." + property + ": "
                    + ex.getMessage(), ex);
        }

        // Get the value for this option
        try {
            beanValue = PropertyUtils.getProperty(bean, value);
            if (beanValue == null) {
                beanValue = "";
            }
        } catch (Exception ex) {
            throw new JspException("Cannot access value ' " + value + " from collection form." + property + ": "
                    + ex.getMessage(), ex);
        }
        String stringLabel = beanLabel.toString();
        String stringValue = beanValue.toString();
        sb.append("<option value=\"").append(escapeHtml ? WebUtils.escapeHtml(stringValue) : stringValue)
                .append("\"");
        if (selTag.hasValue(stringValue) == true) {
            sb.append(" selected=\"selected\"");
        }
        sb.append(" ");
        GWikiTagRenderUtils.renderTagAttributes(this, sb);
        sb.append(">").append(escapeHtml ? WebUtils.escapeHtml(stringLabel) : stringLabel);
        sb.append("</option>");
    }
    GWikiTagRenderUtils.write(pageContext, sb.toString());
    return SKIP_BODY;
}

From source file:com.jaspersoft.jasperserver.war.tags.ParametersFormTag.java

/**
 *
 *///from ww  w  . j  a v a 2  s  .c  om
public int doEndTag() throws JspException {
    try {
        pageContext.include(getRenderJsp());

    } catch (Exception e) {
        log.error(e, e);
        throw new JspException(e);
    }

    return EVAL_PAGE;
}

From source file:com.steeleforge.aem.ironsites.wcm.taglib.SetModeTag.java

@Override
public int doAfterBody() throws JspException {
    BodyContent bc = getBodyContent();//from www . j  a va2  s . c om
    try {
        bc.getEnclosingWriter().print(bc.getString());
    } catch (IOException ioe) {
        LOG.debug(ioe.getMessage());
        throw new JspException(ioe);
    } finally {
        bc = null;
    }
    return SKIP_BODY;
}

From source file:org.osmsurround.tags.NodeEditLinksTag.java

@Override
public int doEndTag() throws JspException {
    try {//w  w w  .ja  v  a2  s . c  o  m
        pageContext.getOut().write(createLinks(node1, node2));
    } catch (IOException e) {
        throw new JspException(e);
    }

    return super.doEndTag();
}