Example usage for javax.servlet.jsp JspWriter println

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

Introduction

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

Prototype


abstract public void println(Object x) throws IOException;

Source Link

Document

Print an Object and then terminate the line.

Usage

From source file:i2p.bote.web.PeerInfoTag.java

@Override
public void doTag() {
    PageContext pageContext = (PageContext) getJspContext();
    JspWriter out = pageContext.getOut();

    try {/*from   w ww.  j a v a2  s  .  c om*/
        // Print DHT peer info
        DhtPeerStats dhtStats = I2PBote.getInstance().getDhtStats();
        if (dhtStats == null)
            return;

        int numDhtPeers = dhtStats.getData().size();

        // Get a sorted list of relay peers
        RelayPeer[] relayPeers = I2PBote.getInstance().getRelayPeers().toArray(new RelayPeer[0]);
        Arrays.sort(relayPeers, new Comparator<RelayPeer>() {
            @Override
            public int compare(RelayPeer peer1, RelayPeer peer2) {
                return peer2.getReachability() - peer1.getReachability();
            }
        });

        // Print charts
        out.println("<div class=\"network-charts\">");
        out.println("<div class=\"chart\">");
        out.println("<img src=\"displayChart?filename=" + createDhtChart(dhtStats) + "\"/>");
        out.println("<div class=\"chart-text\">" + numDhtPeers + "</div>");
        out.println("</div>");
        out.println("<div class=\"chart\">");
        out.println("<img src=\"displayChart?filename=" + createRelayChart(relayPeers) + "\"/>");
        out.println("<div class=\"chart-text\">" + relayPeers.length + "</div>");
        out.println("</div>");
        out.println("</div>");
        out.println("<br>");

        out.println("<span class=\"subheading\">" + _t("Kademlia Peers:") + " " + numDhtPeers + "</span>");
        if (numDhtPeers > 0) {
            out.println("<table");

            // header
            out.println("<tr>");
            for (String columnHeader : dhtStats.getHeader())
                out.println("<th>" + columnHeader + "</th>");
            out.println("</tr>");

            // data
            for (List<String> row : dhtStats.getData()) {
                out.println("<tr>");
                for (String cellData : row)
                    out.println("<td class=\"ellipsis\">" + cellData + "</td>");
                out.println("</tr>");
            }

            out.println("</table>");
        }

        out.println("<br/>");

        // Print relay peer info
        out.println("<span class=\"subheading\">" + _t("Relay Peers:") + " " + relayPeers.length + "</span>");
        if (relayPeers.length > 0) {
            out.println("<table");
            out.println("<tr>");
            out.println("<th>" + _t("Peer") + "</th>");
            out.println("<th>" + _t("I2P Destination") + "</th>");
            out.println("<th>" + _t("Reachability %") + "</th>");
            out.println("</tr>");

            int i = 1;
            for (RelayPeer peer : relayPeers) {
                out.println("<tr>");
                out.println("<td>" + i + "</td>");
                out.println("<td class=\"ellipsis\">" + Util.toBase32(peer) + "</td>");
                int reachability = peer.getReachability();
                out.println("<td>" + (reachability == 0 ? _t("Untested") : reachability) + "</td>");
                out.println("</tr>");
                i++;
            }
            out.println("</table>");
        }

        out.println("<br/>");

        // List banned peers
        Collection<BannedPeer> bannedPeers = I2PBote.getInstance().getBannedPeers();
        out.println("<span class=\"subheading\">" + _t("Banned Peers:") + " " + bannedPeers.size() + "</span>");
        if (bannedPeers.size() > 0) {
            out.println("<table>");
            out.println("<tr>");
            out.println("<th>" + _t("Peer") + "</th>");
            out.println("<th>" + _t("Destination Hash") + "</th>");
            out.println("<th>" + _t("Ban Reason") + "</th>");
            out.println("</tr>");

            int peerIndex = 1;
            for (BannedPeer peer : bannedPeers) {
                out.println("<tr>");
                out.println("<td>" + peerIndex++ + "</td>");
                out.println("<td class=\"ellipsis\">" + Util.toBase32(peer.getDestination()) + "</td>");
                out.println("<td>" + (peer.getBanReason() == null ? "" : peer.getBanReason()) + "</td>");
                out.println("</tr>");
            }

            out.println("</table>");
        }
    } catch (IOException e) {
        log.error("Can't write output to HTML page", e);
    }
}

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

protected void renderPanelHeading(JspWriter out) throws IOException {

    StringWriter headFilterContent = new StringWriter();
    StringWriter titleContent = new StringWriter();
    StringWriter headAddons = new StringWriter();

    renderTitle(titleContent);/*ww  w . j av  a2 s. c  om*/
    if (getPageList().hasFilter()) {
        headFilterContent.append("<div class=\"spacewalk-list-filter\">");
        renderFilterBox(headFilterContent);
        headFilterContent.append("</div>");
    }
    renderHeadExtraAddons(headAddons);

    int headContentLength = headFilterContent.getBuffer().length() + titleContent.getBuffer().length()
            + headAddons.getBuffer().length();

    if (headContentLength > 0) {
        out.println("<div class=\"panel-heading\">");
        out.println(titleContent.toString());
        out.println("<div class=\"spacewalk-list-head-addons\">");
        out.println(headFilterContent.toString());
        out.println("<div class=\"spacewalk-list-head-addons-extra\">");
        out.println(headAddons.toString());
        out.println("</div>");
        out.println("</div>");
        out.println("</div>");
    }
}

From source file:egovframework.rte.ptl.mvc.tags.ui.PaginationTag.java

public int doEndTag() throws JspException {

    try {/*from   w w w  . j  a  v  a  2s.c  o m*/

        JspWriter out = pageContext.getOut();

        PaginationManager paginationManager;

        // WebApplicationContext? id 'paginationManager' ??  Manager .
        WebApplicationContext ctx = RequestContextUtils.getWebApplicationContext(pageContext.getRequest(),
                pageContext.getServletContext());

        if (ctx.containsBean("paginationManager")) {
            paginationManager = (PaginationManager) ctx.getBean("paginationManager");
        } else {
            //bean ?  DefaultPaginationManager . ?   ?? ? ??  .
            paginationManager = new DefaultPaginationManager();
        }

        PaginationRenderer paginationRenderer = paginationManager.getRendererType(type);

        String contents = paginationRenderer.renderPagination(paginationInfo, jsFunction);

        out.println(contents);

        return EVAL_PAGE;

    } catch (IOException e) {
        throw new JspException();
    }
}

From source file:nl.strohalm.cyclos.taglibs.MenuTag.java

@Override
public int doEndTag() throws JspException {
    try {/*from w  ww .  j ava 2 s .c  om*/
        // Rendering is done by the topmost tag. If this is nested, do nothing
        // Also, render something only if there is some content
        if (menu == null || menu.isNested() || !menu.hasContent()) {
            return EVAL_PAGE;
        }
        final JspWriter out = pageContext.getOut();

        // Render this parent menu
        final int index = index();
        final String divId = divId(menu, index);
        renderDiv(menu, index, divId);

        // Render each submenu
        final List<Menu> subMenus = menu.getChildren();
        if (CollectionUtils.isNotEmpty(subMenus)) {
            out.print("<ul id='subMenuContainer" + index + "' class='subMenuContainer' style='display:none'>");
            final int subMenuCount = subMenus.size();
            for (int i = 0; i < subMenuCount; i++) {
                final Menu subMenu = subMenus.get(i);
                final String subMenuId = divId(subMenu, i);
                renderDiv(subMenu, i, subMenuId);
                if (i == 0) {
                    out.println("<script>$('" + subMenuId + "').addClassName('firstSubMenu');</script>");
                } else if (i == subMenuCount - 1) {
                    out.println("<script>$('" + subMenuId + "').addClassName('lastSubMenu');</script>");
                }
            }
            out.println("</ul></li>");
        }
        out.println();
        out.println("<script>allMenus.push($('" + divId + "'));</script>");

        return EVAL_PAGE;
    } catch (final IOException e) {
        throw new JspException(e);
    } finally {
        release();
    }
}

From source file:fll.web.scoreEntry.ScoreEntry.java

/**
 * Generate init for new scores, initializes all variables to their default
 * values.//from  w w  w.  j av  a  2  s. c  o  m
 */
public static void generateInitForNewScore(final JspWriter writer, final ServletContext application)
        throws IOException, ParseException {
    final ChallengeDescription description = ApplicationAttributes.getChallengeDescription(application);
    final PerformanceScoreCategory performanceElement = description.getPerformance();

    for (final AbstractGoal element : performanceElement.getGoals()) {
        if (!element.isComputed()) {
            final Goal goal = (Goal) element;
            final String name = goal.getName();
            final double initialValue = goal.getInitialValue();
            if (goal.isEnumerated()) {
                // find score that matches initialValue or is min
                final List<EnumeratedValue> values = goal.getSortedValues();
                boolean found = false;
                for (final EnumeratedValue valueEle : values) {
                    final String value = valueEle.getValue();
                    final double valueScore = valueEle.getScore();
                    if (FP.equals(valueScore, initialValue, ChallengeParser.INITIAL_VALUE_TOLERANCE)) {
                        writer.println("  " + getVarNameForRawScore(name) + " = \"" + value + "\";");
                        found = true;
                    }
                }
                if (!found) {
                    // fall back to just using the first enum value
                    LOG.warn(String.format(
                            "Initial value for enum goal '%s' does not match the score of any enum value",
                            name));
                    writer.println(
                            "  " + getVarNameForRawScore(name) + " = \"" + values.get(0).getValue() + "\";");
                }

            } else {
                writer.println("  " + getVarNameForRawScore(name) + " = " + initialValue + ";");
            }
        } // !computed
    } // foreach goal

    writer.println("  Verified = 0;");
}

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

/** {@inheritDoc} */
@Override// ww  w.j  a v  a 2  s.  c  o m
public int doAfterBody() throws JspException {
    JspWriter out = null;
    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));
            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.redhat.rhn.frontend.taglibs.ListDisplayTag.java

private void renderActionButtons(JspWriter out) throws IOException {
    if (getPageList().size() == 0 || getButton() == null) {
        return;//from w  w  w.  j av  a 2 s  . co  m
    }

    if (!hasButtonAttrs()) {
        return;
    }

    out.println("<div class=\"col-sm-12 text-right\">");
    if (getButton2() != null
            && AclManager.hasAcl(getButton2Acl(), (HttpServletRequest) pageContext.getRequest(), getMixins())) {

        out.println("<button class=\"btn btn-default\"" + " type=\"submit\" name=\"dispatch\" value=\""
                + LocalizationService.getInstance().getMessage(getButton2()) + "\">"
                + LocalizationService.getInstance().getMessage(getButton2()) + "</button>");
    }
    if (getButton() != null
            && AclManager.hasAcl(getButtonAcl(), (HttpServletRequest) pageContext.getRequest(), getMixins())) {

        out.println("<button class=\"btn btn-primary\"" + " type=\"submit\" name=\"dispatch\" value=\""
                + LocalizationService.getInstance().getMessage(getButton()) + "\">"
                + LocalizationService.getInstance().getMessage(getButton()) + "</button>");
    }
    out.println("</div>");
}

From source file:com.webapp.tags.MainNav.java

public void doTag() throws JspException, IOException {
    JspWriter out = getJspContext().getOut();

    HttpServletRequest request = (HttpServletRequest) ((PageContext) getJspContext()).getRequest();
    String contextPath = request.getContextPath();
    Locale locale = request.getLocale();

    // Retrieve the login for this request
    Login login = WebApp.getLogin(request);

    StringBuffer content = new StringBuffer();
    content.append(/*from  www. jav a2s.c  o  m*/
            "<nav class=\"navbar navbar-default navbar-static-top\" role=\"navigation\" style=\"margin-bottom: 0\">\r\n");

    content.append(navHeader(contextPath, locale, login));
    content.append(navTopLinks(contextPath, locale, login));
    content.append(navSidebar(contextPath, locale, login));

    content.append("\t\t</nav>\r\n");
    content.append("\t\t<!-- / Navigation -->\r\n");

    out.println(content.toString());
}

From source file:org.dspace.app.webui.jsptag.ItemTag.java

/**
 * Render full item record//from ww w .  java 2  s .c om
 */
private void renderFull() throws IOException, SQLException {
    JspWriter out = pageContext.getOut();
    HttpServletRequest request = (HttpServletRequest) pageContext.getRequest();
    Context context = UIUtil.obtainContext(request);

    // Get all the metadata
    DCValue[] values = item.getMetadata(Item.ANY, Item.ANY, Item.ANY, Item.ANY);

    out.println("<p align=\"center\">"
            + LocaleSupport.getLocalizedMessage(pageContext, "org.dspace.app.webui.jsptag.ItemTag.full")
            + "</p>");

    // Three column table - DC field, value, language
    out.println("<center><table class=\"itemDisplayTable\">");
    out.println("<tr><th id=\"s1\" class=\"standard\">"
            + LocaleSupport.getLocalizedMessage(pageContext, "org.dspace.app.webui.jsptag.ItemTag.dcfield")
            + "</th><th id=\"s2\" class=\"standard\">"
            + LocaleSupport.getLocalizedMessage(pageContext, "org.dspace.app.webui.jsptag.ItemTag.value")
            + "</th><th id=\"s3\" class=\"standard\">"
            + LocaleSupport.getLocalizedMessage(pageContext, "org.dspace.app.webui.jsptag.ItemTag.lang")
            + "</th></tr>");

    for (int i = 0; i < values.length; i++) {
        if (!MetadataExposure.isHidden(context, values[i].schema, values[i].element, values[i].qualifier)) {
            out.print("<tr><td headers=\"s1\" class=\"metadataFieldLabel\">");
            out.print(values[i].schema);
            out.print("." + values[i].element);

            if (values[i].qualifier != null) {
                out.print("." + values[i].qualifier);
            }

            out.print("</td><td headers=\"s2\" class=\"metadataFieldValue\">");
            out.print(Utils.addEntities(values[i].value));
            out.print("</td><td headers=\"s3\" class=\"metadataFieldValue\">");

            if (values[i].language == null) {
                out.print("-");
            } else {
                out.print(values[i].language);
            }

            out.println("</td></tr>");
        }
    }

    listCollections();

    out.println("</table></center><br/>");

    listBitstreams();

    if (ConfigurationManager.getBooleanProperty("webui.licence_bundle.show")) {
        out.println("<br/><br/>");
        showLicence();
    }
}

From source file:org.dspace.app.webui.jsptag.ItemTag.java

/**
 * Link to the item licence/* w  w  w.ja v  a 2 s.  c  o  m*/
 */
private void showLicence() throws IOException {
    JspWriter out = pageContext.getOut();
    HttpServletRequest request = (HttpServletRequest) pageContext.getRequest();

    Bundle[] bundles = null;
    try {
        bundles = item.getBundles("LICENSE");
    } catch (SQLException sqle) {
        throw new IOException(sqle.getMessage(), sqle);
    }

    out.println("<table align=\"center\" class=\"attentionTable\"><tr>");

    out.println("<td class=\"attentionCell\"><p><strong>" + LocaleSupport.getLocalizedMessage(pageContext,
            "org.dspace.app.webui.jsptag.ItemTag.itemprotected") + "</strong></p>");

    for (int i = 0; i < bundles.length; i++) {
        Bitstream[] bitstreams = bundles[i].getBitstreams();

        for (int k = 0; k < bitstreams.length; k++) {
            out.print("<div align=\"center\" class=\"standard\">");
            out.print("<strong><a target=\"_blank\" href=\"");
            out.print(request.getContextPath());
            out.print("/retrieve/");
            out.print(bitstreams[k].getID() + "/");
            out.print(UIUtil.encodeBitstreamName(bitstreams[k].getName(), Constants.DEFAULT_ENCODING));
            out.print("\">" + LocaleSupport.getLocalizedMessage(pageContext,
                    "org.dspace.app.webui.jsptag.ItemTag.viewlicence") + "</a></strong></div>");
        }
    }

    out.println("</td></tr></table>");
}