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.redhat.rhn.frontend.taglibs.ToolTipTag.java

/**
 * {@inheritDoc}/*from  w  w  w .  j  av a2 s.  c  o  m*/
 */
@Override
public int doStartTag() throws JspException {
    LocalizationService ls = LocalizationService.getInstance();
    HtmlTag strong = new HtmlTag("strong");
    strong.addBody(ls.getMessage(geTypeKey()) + ": ");

    JspWriter writer = pageContext.getOut();
    try {
        writer.write("<p class=\"small-text\">");
        writer.write(strong.render());
        if (!StringUtils.isBlank(key)) {
            writer.write(ls.getMessage(key));
        }
        return EVAL_BODY_INCLUDE;
    } catch (IOException e) {
        throw new JspException(e);
    }

}

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

/**
 *
 *//*from  w  w w. j ava2  s.c o  m*/
public int doEndTag() throws JspException {
    String baseUrl = null;
    int count = 0;
    // Resin throws ClassCastException with evaluateString for values like "1", so use tmp variable
    Object tmp = null;
    try {
        tmp = ExpressionEvaluationUtils.evaluate("rootUrl", this.rootUrl, pageContext);
        if (tmp != null) {
            baseUrl = tmp.toString();
        }
        count = ExpressionEvaluationUtils.evaluateInteger("total", this.total, pageContext);
        this.pageContext.getOut().print(pagination(baseUrl, count));
    } catch (Exception e) {
        logger.severe("Failure while building pagination object", e);
        throw new JspException(e);
    }
    return EVAL_PAGE;
}

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

/**
 *  Called when a Start tag is processed.
 *
 *@return                   Description of the Return Value
 *@exception  JspException  Description of the Exception
 *///from www.j av a 2 s .  co m
public final int doStartTag() throws JspException {
    try {
        model = ModelUtil.getModel((HttpServletRequest) pageContext.getRequest());
    } catch (Exception e) {
        log.error(e);
        throw new JspException(e);
    }

    pageContext.setAttribute("linkfirst", "ginpservlet?cmd=viewpage&page=first");
    pageContext.setAttribute("linkprev", "ginpservlet?cmd=viewpage&page=prev");
    pageContext.setAttribute("linknext", "ginpservlet?cmd=viewpage&page=next");
    pageContext.setAttribute("linklast", "ginpservlet?cmd=viewpage&page=last");

    if (model.getCollection() != null) {
        pageContext.setAttribute("total", "" + model.getCollection().getPictures().length);
    }

    return EVAL_BODY_INCLUDE;
}

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

/**
 *  Called when a Start tag is processed.
 *
 *@return                   Description of the Return Value
 *@exception  JspException  Description of the Exception
 *///from  www.  j  a va 2s  . c  o m
public final int doStartTag() throws JspException {
    String title = "";
    String description = "";
    String date = "";
    String time = "";

    try {
        model = ModelUtil.getModel((HttpServletRequest) pageContext.getRequest());
    } catch (Exception e) {
        throw new JspException(e);
    }

    try {
        File fl = new File(
                model.getCollection().getRoot() + model.getCollection().getPath() + "ginpfolder.xml");

        if (fl.exists()) {
            FileReader fr = new FileReader(fl);
            LineNumberReader lr = new LineNumberReader(fr);
            StringBuffer sb = new StringBuffer();
            String temp;

            while ((temp = lr.readLine()) != null) {
                sb.append(temp + "\n");
            }

            // Date
            date = StringTool.getXMLTagContent("date", sb.toString());

            if (date != null) {
                pageContext.setAttribute("date", date);
            } else {
                pageContext.setAttribute("date", "");
            }

            // Time
            time = StringTool.getXMLTagContent("time", sb.toString());

            if (time != null) {
                pageContext.setAttribute("time", time);
            } else {
                pageContext.setAttribute("time", "");
            }

            // Title
            temp = StringTool.getXMLTagContent("title", sb.toString());
            title = StringTool.getXMLTagContent(model.getLocale().getLanguage(), temp);

            if (title != null) {
                pageContext.setAttribute("title", title);
            } else {
                pageContext.setAttribute("title", "");
            }

            // description
            temp = StringTool.getXMLTagContent("description", sb.toString());
            description = StringTool.getXMLTagContent(model.getLocale().getLanguage(), temp);

            if (description != null) {
                pageContext.setAttribute("description", description);
            } else {
                pageContext.setAttribute("description", "");
            }

            pageContext.setAttribute("path", model.getCollection().getPath());
            pageContext.setAttribute("colid", "" + model.getCurrCollectionId());
            pageContext.setAttribute("langcode", "" + model.getLocale().getLanguage());

            return EVAL_BODY_AGAIN;
        } else {
            return SKIP_BODY;
        }
    } catch (Exception ex) {
        return SKIP_BODY;
    }
}

From source file:de.micromata.genome.gwiki.page.impl.i18n.GWikiMessageTag.java

@SuppressWarnings("unchecked")
public static void renderPatchDom(PageContext pageContext) throws JspException {
    Object l = pageContext.getAttribute(GWIKI_MESSAGE_ATTR);
    if ((l instanceof List) == false) {
        return;//from  www.  jav  a2s . c o m
    }
    List<GWikiMessageTag> tags = (ArrayList<GWikiMessageTag>) l;
    if (tags.isEmpty() == true) {
        return;
    }
    StringBuilder sb = new StringBuilder();
    sb.append("<script type=\"text/javascript\">gwikiPatchI18NElements([");
    boolean first = true;
    for (GWikiMessageTag tag : tags) {
        if (first == false) {
            sb.append(", ");
        } else {
            first = false;
        }
        sb.append("{ id: '" + tag.getTagId() + "', i18nKey: '" + tag.getKeyAttrValue() + "'}");
    }
    sb.append("]);</script>");

    try {
        pageContext.getOut().write(sb.toString());
    } catch (IOException e) {
        throw new JspException(e);
    }

}

From source file:net.mlw.vlh.web.util.JspUtils.java

/**
 * Write the specified text as the response to the writer associated with
 * this page. <strong>WARNING </strong>- If you are writing body content from
 * the <code>doAfterBody()</code> method of a custom tag class that
 * implements <code>BodyTag</code>, you should be calling
 * <code>writePrevious()</code> instead.
 * /*from  w w  w . j a v a  2  s .co m*/
 * @param pageContext
 *           The PageContext object for this page
 * @param text
 *           The text to be written
 * 
 * @exception JspException
 *               if an input/output error occurs
 */
public static void write(PageContext pageContext, String text) throws JspException {

    JspWriter writer = pageContext.getOut();

    try {
        writer.print(text);
    } catch (IOException e) {
        LOGGER.error("JspUtils.write() exception...", e);
        throw new JspException(e);
    }

}

From source file:org.shredzone.cilla.web.tag.MapMarkerTag.java

@Override
public int doEndTag() throws JspException {
    MapTag parent = TaglibUtils.findAncestorWithType(this, MapTag.class);
    if (parent == null) {
        throw new JspException("<cilla:mapMarker> without parent <cilla:map>");
    }/*  w w  w.  j  a v a  2  s  .c  om*/

    if (text == null) {
        text = getBodyContent().getString();
    }

    parent.addMarker(new Marker(location, text, link));

    return EVAL_PAGE;
}

From source file:com.googlecode.psiprobe.jsp.OutTag.java

private void print(String displayValue, JspWriter out) throws JspException {
    try {/*  w  ww  . j  av a  2  s  .c  om*/
        if (maxLength != -1 && displayValue.length() > maxLength) {
            String newValue;
            if (ellipsisRight) {
                newValue = displayValue.substring(0, maxLength - 3) + "...";
            } else {
                newValue = "..." + displayValue.substring(displayValue.length() - maxLength + 3);
            }
            String title = StringEscapeUtils.escapeHtml(displayValue);
            out.print("<span title=\"" + title + "\">" + newValue + "</span>");
        } else {
            out.print(displayValue);
        }
    } catch (IOException e) {
        throw new JspException(e);
    }
}

From source file:com.laxser.blitz.web.portal.taglibs.PipeWriteTag.java

@Override
public int doStartTag() throws JspException {
    Invocation inv = InvocationUtils.getCurrentThreadInvocation();
    if (inv == null) {
        if (logger.isWarnEnabled()) {
            logger.warn("it is not in a rose request: '"
                    + ((HttpServletRequest) pageContext.getRequest()).getRequestURI() + "'");
        }/*w  w  w  .ja  v a  2  s  .c om*/
        return SKIP_BODY;
    }
    PipeImpl pipe = (PipeImpl) PortalUtils.getPipe(inv);
    if (pipe == null) {
        if (logger.isWarnEnabled()) {
            logger.warn("there is not pipe for this jsp: '"
                    + ((HttpServletRequest) pageContext.getRequest()).getRequestURI() + "'");
        }
        return SKIP_BODY;
    }
    try {
        if (logger.isDebugEnabled()) {
            logger.debug("writing " + pipe + "...");
        }
        pipe.write(pageContext.getOut());

        if (logger.isDebugEnabled()) {
            logger.debug("writing " + pipe + "... done");
        }
    } catch (IOException e) {
        throw new JspException(e);
    }
    return SKIP_BODY;
}

From source file:com.wabacus.system.tags.DataImportTag.java

public int doEndTag() throws JspException {
    if (ref == null || ref.trim().equals("")) {
        throw new JspException("<wx:dataimport/>ref");
    }/* w ww .  j  a  v a2  s.c  o m*/
    BodyContent bc = getBodyContent();
    String label = null;
    if (bc != null)
        label = bc.getString();
    JspWriter out = pageContext.getOut();
    try {
        out.println(TagAssistant.getInstance().getDataImportDisplayValue(ref, this.asyn, this.popupparams,
                this.dataimportinitsize, label, this.interceptor,
                (HttpServletRequest) pageContext.getRequest()));
    } catch (IOException e) {
        log.error("??", e);
    }
    return EVAL_PAGE;
}