Example usage for javax.servlet.jsp JspWriter print

List of usage examples for javax.servlet.jsp JspWriter print

Introduction

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

Prototype


abstract public void print(Object obj) throws IOException;

Source Link

Document

Print an object.

Usage

From source file:org.apache.hadoop.hdfs.server.namenode.JspHelper.java

public void addTableHeader(JspWriter out) throws IOException {
    out.print("<table border=\"1\"" + " cellpadding=\"2\" cellspacing=\"2\">");
    out.print("<tbody>");
}

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

/**
 * {@inheritDoc}/*from   www .j  av a  2 s.  c om*/
 */
@Override
public int doStartTag() throws JspException {
    JspWriter out = null;
    try {
        StringBuffer buf = new StringBuffer();
        out = pageContext.getOut();

        HtmlTag baseTag = new HiddenInputTag();
        if (!StringUtils.isBlank(getId())) {
            baseTag.setAttribute("id", getId());
        }
        baseTag.setAttribute("name", getName());
        baseTag.setAttribute("value", StringEscapeUtils.escapeHtml(getValue()));
        buf.append(baseTag.render());
        out.print(buf.toString());
        return SKIP_BODY;
    } catch (Exception e) {
        throw new JspException("Error writing to JSP file:", e);
    }
}

From source file:com.glaf.core.tag.TagUtils.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.
 * //  w ww  . j a v  a 2 s  .  co m
 * @param pageContext
 *            The PageContext object for this page
 * @param text
 *            The text to be written
 * @throws JspException
 *             if an input/output error occurs (already saved)
 */
public void write(PageContext pageContext, String text) throws JspException {
    JspWriter writer = pageContext.getOut();

    try {
        writer.print(text);
    } catch (IOException e) {
        saveException(pageContext, e);
        throw new JspException(messages.getMessage("write.io", e.toString()));
    }
}

From source file:org.apache.hadoop.hdfs.server.namenode.JspHelper.java

public void addTableRow(JspWriter out, String[] columns) throws IOException {
    out.print("<tr>");
    for (int i = 0; i < columns.length; i++) {
        out.print("<td style=\"vertical-align: top;\"><B>" + columns[i] + "</B><br></td>");
    }/*from  w w  w  .j  a v a  2  s  .  c o  m*/
    out.print("</tr>");
}

From source file:no.kantega.publishing.admin.content.InputScreenRenderer.java

public void renderNormalAttribute(JspWriter out, ServletRequest request,
        Map<String, List<ValidationError>> fieldErrors, Attribute attr) throws IOException {
    request.setAttribute("attribute", attr);
    request.setAttribute("fieldName", AttributeHelper.getInputFieldName(attr.getNameIncludingPath()));

    try {// ww  w  . ja v  a  2  s.  c o  m
        out.print("\n<div class=\"contentAttribute");

        if (fieldErrors.get(attr.getName()) != null) {
            out.print(" error");
        }

        if (attributeIsHiddenEmpty(attr)) {
            this.hiddenAttributes = true;
            out.print(" attributeHiddenEmpty");
        }

        out.print("\" id=\"" + AttributeHelper.getInputContainerName(attr.getNameIncludingPath())
                + "\" data-title=\"" + attr.getTitle() + "\">\n");

        out.print("<div class=\"heading\">" + attr.getTitle());
        if (attr.isMandatory()) {
            out.print("<span class=\"mandatory\">*</span>");
        }
        out.print("</div>");
        String helptext = attr.getHelpText();
        if (helptext != null && helptext.length() > 0) {
            out.print("<div class=\"ui-state-highlight\">" + helptext + "</div>\n");
        }
        String script = attr.getScript();
        if (script != null && script.length() > 0) {
            out.print("<script type=\"text/javascript\">\n" + script + "\n</script>\n");
        }
        if (attr.inheritsFromAncestors()) {
            String inheritText = LocaleLabels.getLabel("aksess.editcontent.inheritsfromancestors",
                    Aksess.getDefaultAdminLocale());
            out.print("<div class=\"ui-state-highlight\">" + inheritText + "</div>\n");
        }
        pageContext.include("/admin/publish/attributes/" + attr.getRenderer() + ".jsp");
        out.print("\n");
        out.print("</div>\n");
    } catch (Exception e) {
        out.print("</div>\n");
        log.error("", e);
        String errorMessage = LocaleLabels.getLabel("aksess.editcontent.exception",
                Aksess.getDefaultAdminLocale());
        out.print("<div class=\"errorText\">" + errorMessage + ":" + attr.getTitle() + "</div>\n");
    }
}

From source file:org.apache.hadoop.hdfs.server.namenode.JspHelper.java

public void addTableRow(JspWriter out, String[] columns, int row) throws IOException {
    out.print("<tr>");

    for (int i = 0; i < columns.length; i++) {
        if (row / 2 * 2 == row) {//even
            out.print("<td style=\"vertical-align: top;background-color:LightGrey;\"><B>" + columns[i]
                    + "</B><br></td>");
        } else {// ww  w. j  av a 2s.c om
            out.print("<td style=\"vertical-align: top;background-color:LightBlue;\"><B>" + columns[i]
                    + "</B><br></td>");

        }
    }
    out.print("</tr>");
}

From source file:psiprobe.jsp.OutTag.java

/**
 * Prints the./*  w  w  w .j  a v a2 s  . c o  m*/
 *
 * @param displayValue the display value
 * @param out the out
 * @throws JspException the jsp exception
 */
private void print(String displayValue, JspWriter out) throws JspException {
    try {
        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.escapeHtml4(displayValue);
            out.print("<span title=\"" + title + "\">" + newValue + "</span>");
        } else {
            out.print(displayValue);
        }
    } catch (IOException e) {
        throw new JspException(e);
    }
}

From source file:org.codelabor.system.web.taglib.SystemPropertiesTag.java

@Override
public void doTag() throws JspException, IOException {
    logger.debug("doTag");
    logger.debug("emptyString: {}", emptyString);
    logger.debug("escapeHtml: {}", escapeHtml);

    JspWriter out = getJspContext().getOut();
    String value = System.getProperty(key);
    String effectiveValue = null;

    if (value != null) {
        if (escapeHtml) {
            effectiveValue = StringEscapeUtils.escapeHtml4(value);
        } else {/*from w  w  w  .j  a v  a 2 s  .c o  m*/
            effectiveValue = value;
        }
    } else {
        if (emptyString) {
            effectiveValue = "";
        }
    }
    logger.debug("key: {}, value: {}, effectiveValue: {}", key, value, effectiveValue);
    out.print(effectiveValue);
}

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

/**
 * <p>Description:buildRefresh</p>
 * @param request   /*w  w w . j  av  a2s . c o m*/
 * @param pageNo 
 * @return void
 * @author wenzhi
 * @version 1.0
 * @exception JspException
 */
@SuppressWarnings("unused")
private void buildRefresh(HttpServletRequest request, int pageNo) throws JspException {
    try {
        JspWriter out = pageContext.getOut();
        StringBuffer outString = new StringBuffer(50);
        outString.append("<a href=\"javascript:setPage('" + pageNo + "','" + targets + "');\">");
        outString.append("</a>");
        out.print(outString.toString());
    } catch (Exception e) {
        throw new JspException(e);
    }
}

From source file:com.wlt.webm.util.PageTag.java

public int doEndTag() throws JspTagException {
    //style,()/*from  w w w  .ja  va  2 s .com*/
    StringBuffer buf = new StringBuffer();
    if ("green".equals(style)) {
        //
        getGreenPageinfo(buf);
    } else if ("blue".equals(style)) {
        //
        getBluePageinfo(buf);
    } else if ("red".equals(style)) {
        getRedPageinfo(buf);
    } else if ("black".equals(style)) {
        //getBlackPageinfo(buf);
        getBluePageinfo(buf);
    }
    JspWriter out = pageContext.getOut();
    try {
        out.print(buf.toString());
    } catch (IOException e) {
        log.error("" + e.getMessage());
        e.printStackTrace();
    }
    return SKIP_BODY;
}