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.jsmartframework.web.manager.TagHandler.java

public void addParam(String key, Object value) throws JspException {
    if (params.containsKey(key)) {
        throw new JspException("Duplicated tag parameter " + key);
    }//from   w ww  .j av a  2  s  . co m
    params.put(key, value);
}

From source file:com.redhat.rhn.frontend.taglibs.list.ListTag.java

/**
 * Sets the name of the dataset to use Tries to locate the list in the
 * following order: page context, request attribute, session attribute
 *
 * @param nameIn name of dataset//from  w  w w. j a  v  a  2 s . c  om
 * @throws JspException indicates something went wrong
 */
public void setDataset(String nameIn) throws JspException {
    dataSetName = nameIn;
    Object d = pageContext.getAttribute(nameIn);
    if (d == null) {
        d = pageContext.getRequest().getAttribute(nameIn);
    }
    if (d == null) {
        HttpServletRequest request = (HttpServletRequest) pageContext.getRequest();
        d = request.getSession(true).getAttribute(nameIn);
    }
    if (d != null) {
        if (d instanceof List) {
            pageData = (List) d;
        } else {
            throw new JspException("Dataset named \'" + nameIn + "\' is incompatible."
                    + " Must be an an instance of java.util.List.");
        }
    } else {
        pageData = Collections.EMPTY_LIST;
    }
}

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

/** {@inheritDoc} */
public int doEndTag() throws JspException {
    JspWriter out = null;// ww  w.ja va 2s .co m
    try {
        if (getPageList().isEmpty()) {
            return EVAL_PAGE;
        }

        if (isExport()) {
            ExportWriter eh = createExportWriter();
            String[] columns = StringUtils.split(this.getExportColumns(), ',');
            eh.setColumns(Arrays.asList(columns));
            ServletExportHandler seh = new ServletExportHandler(eh);
            pageContext.getOut().clear();
            pageContext.getOut().clearBuffer();
            pageContext.getResponse().reset();
            seh.writeExporterToOutput((HttpServletResponse) pageContext.getResponse(), getPageList());
            return SKIP_PAGE;
        }

        // Get the JSPWriter that the body used, then pop the
        // bodyContent, so that we can get the real JspWriter with getOut.
        BodyContent body = getBodyContent();
        pageContext.popBody();
        out = pageContext.getOut();

        if (body != null) {
            String bodyString = body.getString();
            out.println(bodyString);
        }
        // Rely on content to have emitted a tbody tag somewhere
        out.println("</tbody>");
        out.println("</table>\n");
        out.println("</div>\n");
        out.println("</div>\n");
        setNumberOfColumns(0);
        setColumnCount(0);
        setCurrRow(0);

    } catch (IOException e) {
        throw new JspException("IO error" + e.getMessage());
    } finally {
        pageContext.setAttribute("current", null);
    }

    return EVAL_PAGE;
}

From source file:com.xhsoft.framework.common.page.WebappPageTag.java

/**
 * <p>Description:?</p>//w  w w  .  java2 s  .  com
 * @param  pageNo   
 * @param request 
 * @return void
 * @author wenzhi
 * @version 1.0
 * @exception JspException
 */
private void printOutFront(int pageNo, HttpServletRequest request) throws JspException {

    try {
        String first = "";
        String prev = "";
        JspWriter out = pageContext.getOut();
        String outString = "";
        if (pageNo == 1) {
            outString = "" + " " + first + "&nbsp;|&nbsp;" + " " + prev + "&nbsp;|&nbsp;";
        } else {
            Integer prePage = new Integer(pageNo == 1 ? pageNo : pageNo - 1);
            outString = "" + "<a href=\"" + link + "qm.pn=" + 1 + "\">" + first + "&nbsp;</a>|" + "<a href=\""
                    + link + "qm.pn=" + prePage + "\">" + prev + "&nbsp;</a>|";
        }
        out.print(outString);
    } catch (Exception e) {
        throw new JspException(e);
    }

}

From source file:com.xhsoft.framework.common.page.PageTag.java

/**
 * <p>Description: ?</p>//from w w  w  .  j a v  a2s.  c o m
 * @param pageNo 
 * @param request
 * @return void
 * @author wenzhi
 * @version 1.0
 * @exception JspException
 */
private void printOutFront(int pageNo, HttpServletRequest request) throws JspException {

    try {
        String first = "";
        String prev = "";
        JspWriter out = pageContext.getOut();
        String outString = "";
        if (pageNo == 1) {
            outString = "" + " " + first + "&nbsp;&nbsp;" + " " + prev + "&nbsp;&nbsp;";
        } else {
            Integer prePage = new Integer(pageNo == 1 ? pageNo : pageNo - 1);
            outString = "" + "<a href=\"javascript:setPage('" + 1 + "','" + targets + "');\">" + first
                    + "&nbsp;</a>&nbsp;" + "<a href=\"javascript:setPage('" + prePage + "','" + targets
                    + "');\">" + prev + "&nbsp;</a>&nbsp;";
        }
        out.print(outString);
    } catch (Exception e) {
        throw new JspException(e);
    }

}

From source file:com.redhat.rhn.frontend.taglibs.list.ListTag.java

/**
 * Name used to store the currentObject in the page
 * @param nameIn row name/*from w  ww  .  ja  v a2 s.c om*/
 * @throws JspException if row name is empty
 */
public void setRowname(String nameIn) throws JspException {
    if (rowName == null || rowName.length() == 0) {
        throw new JspException("Row name cannot be empty");
    }
    rowName = nameIn;
}

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

/** {@inheritDoc} */
public int doAfterBody() throws JspException {
    JspWriter out = null;/*w ww  . jav  a 2 s  .com*/
    try {
        out = pageContext.getOut();

        if (pageContext.getAttribute("current") == null) {
            out.println("</tr>");
            out.println("</thead>");
            out.println("<tbody>");
        } else {
            out.println("</tr>");
        }

        if (getIterator().hasNext()) {
            setColumnCount(0);
            Object next = getIterator().next();
            out.println(getTrElement(next, currRow++));
            pageContext.setAttribute("current", next);
            return EVAL_BODY_AGAIN;
        }
    } catch (IOException e) {
        throw new JspException("Error while writing to JSP: " + e.getMessage());
    }

    return SKIP_BODY;
}

From source file:com.xhsoft.framework.common.page.WebappPageTag.java

/**
 * <p>Description:?</p>//  w  w  w  . j ava2s . c  o  m
 * @param  pageNo   
 * @param totalPages 
 * @param request 
 * @return void
 * @author wenzhi
 * @version 1.0
 * @exception JspException
 */
private void printOutBack(int pageNo, int totalPages, HttpServletRequest request) throws JspException {
    try {
        Integer nextPage = new Integer(pageNo == totalPages ? totalPages : pageNo + 1);
        String next = "";
        String last = "?";
        JspWriter out = pageContext.getOut();
        String outString = "";

        if (pageNo == totalPages || totalPages == 0 || totalPages == 1) {
            outString = " "

                    + next + "&nbsp;|&nbsp;" + " " + last + "&nbsp;|&nbsp;";
        } else {
            outString = " " + "<a href=\"" + link + "qm.pn=" + nextPage + "\">" + next + "&nbsp;</a>|"
                    + "<a href=\"" + link + "qm.pn=" + totalPages + "\">" + last + "&nbsp;</a>|&nbsp;&nbsp;";
        }
        out.print(outString);
    } catch (Exception e) {
        throw new JspException(e);
    }
}

From source file:com.xhsoft.framework.common.page.WebappPageTag.java

/**
 * <p>Description: ?</p>/*from   w ww .j  a  v a2 s. c o  m*/
 * @return void
 * @author wenzhi
 * @version 1.0
 * @exception JspException
 */
private void printOutEnd() throws JspException {
    try {
        JspWriter out = pageContext.getOut();
        String outString = "";
        out.print(outString);
    } catch (Exception e) {
        throw new JspException(e);
    }
}

From source file:it.eng.spagobi.commons.presentation.tags.ListTag.java

protected void defineColumns() throws JspException {
    _columns = new Vector();
    _titleButton = new Vector();
    List columnsVector = _layout.getAttributeAsList("COLUMNS.COLUMN");
    for (int i = 0; i < columnsVector.size(); i++) {
        String hidden = (String) ((SourceBean) columnsVector.get(i)).getAttribute("HIDDEN");
        if (hidden == null || hidden.trim().equalsIgnoreCase("FALSE")) {
            SourceBean sb = (SourceBean) columnsVector.get(i);
            _columns.add(sb);/*w  ww . j a  v a2 s .c  o m*/

            // check if there are columsn buttons   
            SourceBean sbButton = (SourceBean) sb.getAttribute("BUTTONS");
            if (sbButton != null) {
                List buttons = sbButton.getContainedSourceBeanAttributes();
                _titleButton.add(buttons);
                //makeTitleButton(buttons);
            } else {
                _titleButton.add(new ArrayList());
            }
        }

    }
    if ((_columns == null) || (_columns.size() == 0)) {
        logger.error("Columns names not defined");
        throw new JspException("Columns names not defined");
    }
}