Example usage for javax.servlet.jsp PageContext getOut

List of usage examples for javax.servlet.jsp PageContext getOut

Introduction

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

Prototype

abstract public JspWriter getOut();

Source Link

Document

The current value of the out object (a JspWriter).

Usage

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

public static void write(PageContext pageContext, String data) throws JspException {
    try {/*  ww  w  . j  a  v a  2 s.  c o  m*/
        pageContext.getOut().write(data);
    } catch (IOException e) {
        throw new JspException("Failure writing tag", 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  va2 s . com
 * @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:net.mlw.vlh.web.util.JspUtils.java

/**
 * Write the specified text as the response to the writer associated with the
 * body content for the tag within which we are currently nested.
 * //from   www.  jav a  2s.  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 writePrevious(PageContext pageContext, String text) throws JspException {
    JspWriter writer = pageContext.getOut();
    if (writer instanceof BodyContent) {
        writer = ((BodyContent) writer).getEnclosingWriter();
    }

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

}

From source file:jp.terasoluna.fw.web.taglib.TagUtil.java

/**
 * PageContextJspWriter?AweLXg?o?B//from   ww w . java2s .  com
 * ?s?B
 * 
 * @param pageContext y?[WReLXg
 * @param text ?oeLXg
 * @throws JspException
 * I/OG?[???IOExceptionbvO
 */
public static void write(PageContext pageContext, String text) throws JspException {
    JspWriter writer = pageContext.getOut();
    try {
        writer.print(text);
    } catch (IOException e) {
        throw new JspException(e);
    }
}

From source file:jp.terasoluna.fw.web.taglib.TagUtil.java

/**
 * PageContextJspWriter?AweLXg?o?B/*from ww  w  .  j av  a 2s. c o m*/
 * ?s?B
 * 
 * @param pageContext y?[WReLXg
 * @param text ?oeLXg
 * @throws JspException
 * I/OG?[???IOExceptionbvO
 */
public static void writeln(PageContext pageContext, String text) throws JspException {
    JspWriter writer = pageContext.getOut();
    try {
        writer.println(text);
    } catch (IOException e) {
        throw new JspException(e);
    }
}

From source file:de.iteratec.iteraplan.presentation.tags.TagUtils.java

/**
 * Write the specified text as the response to the writer associated with this page.
 * // w  w w.  j a v  a2  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
 */
public static void write(PageContext pageContext, String text) throws JspException {
    JspWriter writer = pageContext.getOut();

    try {
        writer.print(text);
    } catch (IOException e) {
        throw new JspException("An I/O error ocurred: ", e);
    }
}

From source file:de.iteratec.iteraplan.presentation.tags.TagUtils.java

public static void insertImage(PageContext ctx, String image, int width, int height) throws IOException {
    JspWriter w = ctx.getOut();
    String alt = "";

    w.print("<img src=\"");
    w.print(ctx.getServletContext().getContextPath());
    w.print(image);//from   w ww . j av  a 2  s .  c om
    w.println("\" style=\"float: right;\" width=\"" + width + "\" height=\"" + height + "\" alt=\"" + alt
            + "\" />");
}

From source file:de.iteratec.iteraplan.presentation.tags.TagUtils.java

/**
 * This method will print the literal (if given) or else the value of the key
 * /*  w w w .ja  v  a  2  s  . c om*/
 * @param ctx
 * @param literal
 * @param key
 * @throws JspException
 * @throws IOException
 */
public static void insertMessage(PageContext ctx, String literal, String key) throws JspException, IOException {
    JspWriter w = ctx.getOut();

    if (literal != null && literal.length() != 0) {
        w.println(literal);
    }

    MessageTag messageTag = new MessageTag();
    messageTag.doStartTag();
    messageTag.setPageContext(ctx);
    messageTag.setKey(key);
    messageTag.doEndTag();
}

From source file:de.micromata.genome.gwiki.page.gspt.TagSupport.java

/**
 * @return true if body should be included
 *///from   w w  w .j  a  va  2s . com
public static boolean initTag(Tag tag, List<Object> attributes, ChildPageContext ctx) throws Exception {
    Tag ptag = ctx.getCurrentTag();
    if (log.isDebugEnabled())
        log.debug("Init tag: " + tag.getClass().getName());

    PageContext pctx = ctx;
    if (ctx.isUseParentTagContext() == true)
        pctx = ctx.getParentPageContext();
    tag.setPageContext(pctx);
    tag.setParent(ptag);
    attributes = evalAttributes(tag, attributes, ctx);
    setAttributes(tag, attributes, ctx);
    ctx.setCurrentTag(tag);
    int r = tag.doStartTag();
    ctx.getTagStack().push(new Pair<Tag, Integer>(tag, r));
    JspWriter oout = pctx.getOut();
    ctx.setInternalGroovyOut(createPrintWriter(oout));
    if (r != javax.servlet.jsp.tagext.Tag.SKIP_BODY && r != javax.servlet.jsp.tagext.Tag.EVAL_BODY_INCLUDE
            && tag instanceof BodyTag) {

        BodyTag btag = (BodyTag) tag;

        JspWriter out = pctx.pushBody();
        PrintWriterPatched newPout = createPrintWriter(out, true);
        ctx.setInternalGroovyOut(newPout);

        btag.setBodyContent((javax.servlet.jsp.tagext.BodyContent) out);
        btag.doInitBody();
    }
    boolean ret = r != javax.servlet.jsp.tagext.Tag.SKIP_BODY;
    if (log.isDebugEnabled())
        log.debug("Init tag: " + tag.getClass().getName() + ": " + ret);
    return ret;
}

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

/**
 * Writes arbitrary text to the client (browser)
 * @param ctx caller's page context//from w  ww  . j a  v a2 s  . c  o  m
 * @param text text to write
 * @throws JspException if an error occurs
 */
public static void write(PageContext ctx, String text) throws JspException {
    if (text == null) {
        text = "null";
    }
    Writer writer = ctx.getOut();
    try {
        writer.write(text);
    } catch (IOException e) {
        throw new JspException(e);
    }
}