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:com.wabacus.system.tags.component.AbsComponentTag.java

public int doStartTag() throws JspException {
    initTagState();//ww  w .j a v a  2  s. c o m
    request = (HttpServletRequest) pageContext.getRequest();
    out = pageContext.getOut();
    rrequest = (ReportRequest) request.getAttribute("WX_REPORTREQUEST");
    this.ownerComponentObj = (AbsReportType) request.getAttribute("WX_COMPONENT_OBJ");
    rrequest.getWResponse().setJspout(this.out);
    if (isRootTag()) {
        if (rrequest == null)
            throw new JspException("?ReportRequest");
        if (this.ownerComponentObj == null)
            throw new JspException("?");
    }
    initDisplayComponentObj();
    try {
        return doMyStartTag();
    } catch (Exception e) {
        log.error("?" + rrequest.getPagebean().getId() + "", e);
        rrequest.getWResponse().getMessageCollector().error("?", null, true);
        return SKIP_BODY;
    }
}

From source file:alpha.portal.webapp.taglib.ConstantsTag.java

/**
 * Main method that does processing and exposes Constants in specified
 * scope.//from w w  w  .j av  a 2  s. c o  m
 * 
 * @return int
 * @throws JspException
 *             if processing fails
 */
@Override
public int doStartTag() throws JspException {
    // Using reflection, get the available field names in the class
    Class c = null;
    int toScope = PageContext.PAGE_SCOPE;

    if (this.scope != null) {
        toScope = this.getScope(this.scope);
    }

    try {
        c = Class.forName(this.clazz);
    } catch (final ClassNotFoundException cnf) {
        this.log.error("ClassNotFound - maybe a typo?");
        throw new JspException(cnf.getMessage());
    }

    try {
        // if var is null, expose all variables
        if (this.var == null) {
            final Field[] fields = c.getDeclaredFields();

            AccessibleObject.setAccessible(fields, true);

            for (final Field field : fields) {
                this.pageContext.setAttribute(field.getName(), field.get(this), toScope);
            }
        } else {
            try {
                final Object value = c.getField(this.var).get(this);
                this.pageContext.setAttribute(c.getField(this.var).getName(), value, toScope);
            } catch (final NoSuchFieldException nsf) {
                this.log.error(nsf.getMessage());
                throw new JspException(nsf);
            }
        }
    } catch (final IllegalAccessException iae) {
        this.log.error("Illegal Access Exception - maybe a classloader issue?");
        throw new JspException(iae);
    }

    // Continue processing this page
    return (Tag.SKIP_BODY);
}

From source file:gov.nih.nci.ncicb.cadsr.common.jsp.tag.handler.AvailableValidValue.java

public int doStartTag() throws javax.servlet.jsp.JspException {
    HttpServletRequest req;/*from   w  ww . ja  v a  2s .  c  om*/
    JspWriter out;
    try {
        req = (HttpServletRequest) pageContext.getRequest();
        out = pageContext.getOut();
        pageContext.setAttribute(AVAILABLE_VALID_VALUE_PRESENT, null);
        Question currQuestion = (Question) pageContext.getAttribute(questionBeanId);
        Map availableVVMap = (Map) pageContext.getSession().getAttribute(availableValidValusMapId);
        List questionVVList = currQuestion.getValidValues();
        String questionIdSeq = currQuestion.getQuesIdseq();
        List availableVVs = (List) availableVVMap.get(questionIdSeq);
        List nonListedVVs = (List) pageContext.getAttribute(questionIdSeq + "NotListedValidValues");

        if (nonListedVVs == null && (availableVVs != null && !availableVVs.isEmpty())) {
            nonListedVVs = getNotListedValidValues(currQuestion.getValidValues(), availableVVs);
            pageContext.setAttribute(questionIdSeq + "NotListedValidValues", nonListedVVs);
        }

        if (availableVVs != null && !availableVVs.isEmpty()) {

            //List nonListedVVs = getNotListedValidValues(currQuestion.getValidValues(),availableVVs);
            if (!nonListedVVs.isEmpty()) {
                String html = generateHtml(nonListedVVs, availableVVs, questionIdSeq);
                out.print(html);
                pageContext.setAttribute(AVAILABLE_VALID_VALUE_PRESENT, "Yes");

            } else {
                out.print(" ");
                pageContext.removeAttribute(AVAILABLE_VALID_VALUE_PRESENT);
            }
        } else {
            pageContext.removeAttribute(AVAILABLE_VALID_VALUE_PRESENT);
            out.print(" ");
        }

    } catch (Exception ioe) {
        throw new JspException("I/O Error : " + ioe.getMessage());
    } //end try/catch
    return Tag.SKIP_BODY;

}

From source file:com.steeleforge.aem.ironsites.i18n.taglib.I18nHelperTag.java

public int doEndTag() throws JspException {
    try {/*from  w w w  .  j a  v a 2 s . co  m*/
        init();

        ValueMap valueMap = request.getResource().adaptTo(ValueMap.class);
        I18nResourceBundle bundle = new I18nResourceBundle(valueMap, getResourceBundle(getBaseName(), request));

        // make this resource bundle & i18n available as ValueMap for TEI
        pageContext.setAttribute(getMessagesName(), bundle.adaptTo(ValueMap.class), PageContext.PAGE_SCOPE);
        pageContext.setAttribute(getI18nName(), new I18n(bundle), PageContext.PAGE_SCOPE);

        // make this resource bundle available for fmt functions
        Config.set(pageContext, "javax.servlet.jsp.jstl.fmt.localizationContext",
                new LocalizationContext(bundle, getLocale(request)), 1);
    } catch (Exception e) {
        LOG.error(e.getMessage());
        throw new JspException(e);
    }
    return EVAL_PAGE;
}

From source file:de.laures.cewolf.taglib.tags.ChartImgTag.java

public int doStartTag() throws JspException {
    final ChartHolder chartHolder = PageUtils.getChartHolder(chartId, pageContext);
    this.chartImageDefinition = new ChartImageDefinition(chartHolder, width, height, ChartImage.IMG_TYPE_CHART,
            mimeType, timeout);//from  w ww  . jav  a2s  . c om
    Storage storage = Configuration.getInstance(pageContext.getServletContext()).getStorage();
    try {
        this.sessionKey = storage.storeChartImage(chartImageDefinition, pageContext);
    } catch (CewolfException cwex) {
        throw new JspException(cwex.getMessage());
    }
    return EVAL_PAGE;
}

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

public int doStartTag() throws JspException {
    HttpServletRequest request = (HttpServletRequest) pageContext.getRequest();
    WebApplicationContext applicationContext = RequestContextUtils.getWebApplicationContext(request);

    Locale locale = RequestContextUtils.getLocale(request);
    TimeZone timezone = JasperServerUtil.getTimezone(request);

    String formattingPattern = getFormattingPattern(applicationContext, locale);
    SimpleDateFormat format = new SimpleDateFormat(formattingPattern, locale);
    format.setTimeZone(timezone);//from  w w w.j ava 2  s .  c  om

    String formattedValue = format.format(getValue());

    try {
        //TODO html escaping?
        pageContext.getOut().write(formattedValue);
    } catch (IOException e) {
        log.error(e);
        throw new JspException(e);
    }

    return SKIP_BODY;
}

From source file:com.trailmagic.image.ui.ImageGroupLinkTag.java

public int doEndTag() throws JspException {
    try {/*www.ja va 2s  .c  om*/
        pageContext.getOut().write("</a>");
        return EVAL_PAGE;
    } catch (IOException e) {
        throw new JspException(e);
    }
}

From source file:com.trenako.web.tags.AvatarTags.java

@Override
protected int writeTagContent(JspWriter jspWriter, String contextPath) throws JspException {

    Account account = userService.findBySlug(getUser());
    if (account == null) {
        return SKIP_BODY;
    }/*from  w ww . j a  v  a2  s . c o m*/

    String gravatarImageURL = new Gravatar().setSize(getSize()).setHttps(true)
            .setRating(Rating.PARENTAL_GUIDANCE_SUGGESTED).setStandardDefaultImage(DefaultImage.MYSTERY_MAN)
            .getUrl(account.getEmailAddress());

    try {
        StringBuilder sb = new StringBuilder();

        if (showGravatarLink()) {
            sb.append("\n<a href=\"http://gravatar.com/emails/\">");
        }

        sb.append("\n<img ").append("height=\"").append(getSize()).append("\" ").append("width=\"")
                .append(getSize()).append("\" ").append("src=\"").append(gravatarImageURL).append("\" />");

        if (showGravatarLink()) {
            sb.append("\n</a>");
        }

        if (showUsername()) {
            sb.append("\n<br/>");
            sb.append("\n" + account.getDisplayName());
        }

        jspWriter.append(sb.toString());
    } catch (IOException e) {
        throw new JspException(e);
    }

    return SKIP_BODY;
}

From source file:com.adito.input.tags.MultiEntryListBoxTag.java

public int doStartTag() throws JspException {

    String entryTitle = null;// w w w  . j  a v  a 2  s.  c  om
    if (entryTitleKey != null) {
        entryTitle = TagUtils.getInstance().message(pageContext, getBundle(), getLocale(), entryTitleKey,
                new String[] {});

        if (entryTitle == null) {
            JspException e = new JspException(
                    messages.getMessage("message.message", "\"" + entryTitleKey + "\""));
            TagUtils.getInstance().saveException(pageContext, e);
            throw e;
        }
    }

    String targetTitle = prepareTargetTitle();

    StringBuffer results = new StringBuffer("<div ");
    results.append(prepareStyles());
    results.append(">");
    results.append(this.renderInputElement());
    results.append("<table cellpadding=\"0\" cellspacing=\"0\" border=\"0\">");
    if (entryTitle != null || targetTitle != null) {
        results.append("<tr class=\"header\"><td class=\"entry\">");
        if (entryTitle != null) {
            results.append(entryTitle);
        }
        results.append("</td><td class=\"actions\"/><td class=\"target\">");
        if (targetTitle != null) {
            results.append(targetTitle);
        }
        results.append("</td></tr>");
    }
    results.append("<tr class=\"body\"><td class=\"entry\">");
    results.append(renderEntryComponent());
    results.append("</td><td class=\"actions\"><table cellpadding=\"0\" cellspacing=\"0\" border=\"0\">");
    results.append("<tr><td>");
    results.append(renderAddComponent());
    results.append("</td></tr><tr><td>");
    results.append(renderRemoveSelectedComponent());
    if (isAllowReordering()) {
        results.append("</td></tr><tr><td>");
        results.append(renderUpComponent());
        results.append("</td></tr><tr><td>");
        results.append(renderDownComponent());
    }
    results.append("</td></tr></table></td><td class=\"target\">");
    results.append(renderTargetComponent());
    results.append("</td></tr></table></div>");
    TagUtils.getInstance().write(this.pageContext, results.toString());

    return (EVAL_BODY_BUFFERED);
}

From source file:net.mlw.vlh.web.tag.ValueListRetriever.java

/**
 * @see javax.servlet.jsp.tagext.Tag#doEndTag()
 *//*  w w  w .  ja v  a 2  s. com*/
public int doEndTag() throws JspException {
    ValueListSpaceTag rootTag = (ValueListSpaceTag) JspUtils.getParent(this, ValueListSpaceTag.class);

    ValueListInfo info = ValueListRequestUtil.buildValueListInfo((HttpServletRequest) pageContext.getRequest(),
            rootTag.getTableInfo().getId());
    info.getFilters().putAll(getCellAttributes().getMap());

    WebApplicationContext context = WebApplicationContextUtils
            .getWebApplicationContext(pageContext.getServletContext());

    if (context == null) {
        final String message = "Cannot locate the spring WebApplicationContext. Is it configured in your web.xml?";
        LOGGER.error(message);
        throw new JspException(message);
    }

    //      ValueListHandler vlh = (ValueListHandler) context.getBean(ValueListHandler.DEFAULT_SERVICE_NAME, ValueListHandler.class);
    //      if (vlh == null)
    //      {
    //         final String message = "Cannot locate the ValueListHanlder in the WebApplicationContext, under the name: \""
    //               + ValueListHandler.DEFAULT_SERVICE_NAME + "\"";
    //         LOGGER.error(message);
    //         throw new JspException(message);
    //      }

    info.setFocusValue(focusValue);
    info.setFocusProperty(focusProperty);

    if (LOGGER.isDebugEnabled()) {
        LOGGER.debug("Focus settings was setted up. Focus property '" + focusProperty + "', focus value '"
                + focusValue + "'");
    }

    //      ValueList list = vlh.getValueList(valueListName, info);
    //      pageContext.getRequest().setAttribute(rootTag.getTableInfo().getName(), list);
    ValueList list = (ValueList) pageContext.getRequest().getAttribute(rootTag.getTableInfo().getName());
    if (list == null) {
        final String message = "Cannot locate the ValueList in the WebApplicationContext ";
        LOGGER.error(message);
        throw new JspException(message);
    }
    rootTag.setValueList(list);

    if (LOGGER.isDebugEnabled()) {
        LOGGER.debug("ValueList was retrieved from adapter inside of the jsp.");
    }

    release();

    return EVAL_PAGE;
}