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:cn.vlabs.umt.ui.tags.SsoParamsTag.java

public int doEndTag() throws JspException {
    ServletRequest request = pageContext.getRequest();
    JspWriter writer = pageContext.getOut();
    for (String param : Attributes.SSO_PARAMS) {
        String value = request.getParameter(param);
        if (StringUtils.isNotBlank(value)) {
            try {
                writer.println(String.format("<input type=\"hidden\" name=\"%s\" value=\"%s\">", param, value));
            } catch (IOException e) {
                throw new JspException(e);
            }// ww w  .j a va 2  s .c  o  m
        }
    }
    return EVAL_PAGE;
}

From source file:io.undertow.test.jsp.expression.ExpressionJspTestCase.java

public static void evaluate(JspWriter out, PageContext pc, String qualifiedMethodExpression,
        String unqualifiedMethodExpression, String variableExpression) throws Exception {
    assert pc != null;
    TSFunctionMapper mapper = new TSFunctionMapper();
    ExpressionEvaluator eval = pc.getExpressionEvaluator();
    VariableResolver resolver = pc.getVariableResolver();
    assert eval != null : "Unable to obtain ExpressionEvaluator";
    Expression expr = eval.parseExpression(qualifiedMethodExpression, java.lang.String.class, mapper);
    assert expr != null;
    String result = (String) expr.evaluate(resolver);
    if (result != null) {
        if (result.equals("string")) {
            Expression expr2 = eval.parseExpression(variableExpression, javax.servlet.jsp.PageContext.class,
                    null);//from w w  w .j  a  v  a 2 s .co  m
            if (expr2 != null) {
                PageContext pageContext = (PageContext) expr2.evaluate(resolver);
                if (pageContext != pc) {
                    out.println("Test FAILED.  Resolution didn't return expected value.");
                    out.println("PageContext returned is not the same instance as expected.");
                }
                Expression expr3 = eval.parseExpression(unqualifiedMethodExpression, java.lang.String.class,
                        mapper);
                if (expr3 != null) {
                    result = (String) expr3.evaluate(resolver);
                    if (result != null) {
                        if (result.equals("string")) {
                            out.println("Test PASSED");
                        } else {
                            out.println("Test FAILED. (l3) Expression evaluation returned unexpected value.");
                            out.println("Expected 'string', received '" + result + "'");
                        }
                    } else {
                        out.println("Test FAILED.  (l3) Expression evaluation returned null.");
                    }
                } else {
                    out.println("Test FAILED. (l3) ExpressionEvaluator.parseExpression" + " returned null.");
                }
            } else {
                out.println("Test FAILED. (l2) ExpressionEvaluator returned null.");
            }
        } else {
            out.println("Test FAILED.  (l1) Expression evaluation returned unexpected result.");
            out.println("Expected 'string', Received '" + result + "'");
        }
    } else {
        out.println("Test FAILED. (l1) Expression evaluation returned null.");
    }

}

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

/**
 * Generate the isConsistent method for the goals in the performance element
 * of document.//ww w  . ja va  2  s  .c o  m
 */
public static void generateIsConsistent(final JspWriter writer, final ServletContext application)
        throws IOException {
    final ChallengeDescription descriptor = ApplicationAttributes.getChallengeDescription(application);
    final PerformanceScoreCategory performanceElement = descriptor.getPerformance();

    writer.println("function isConsistent() {");

    // check all goal min and max values
    for (final AbstractGoal element : performanceElement.getGoals()) {
        if (!element.isComputed()) {
            final Goal goal = (Goal) element;
            final String name = goal.getName();
            final double min = goal.getMin();
            final double max = goal.getMax();

            writer.println("  <!-- " + name + " -->");
            if (goal.isEnumerated()) {
                // enumerated
                writer.println("  <!-- nothing to check -->");
            } else {
                final String rawVarName = getVarNameForRawScore(name);
                writer.println("  if(" + rawVarName + " < " + min + " || " + rawVarName + " > " + max + ") {");
                writer.println("    return false;");
                writer.println("  }");
            }
            writer.println();
        } // !computed
    } // foreach goal

    writer.println("  return true;");
    writer.println("}");
}

From source file:org.broadleafcommerce.core.web.catalog.taglib.SearchFilterItemTag.java

@Override
public void doTag() throws JspException, IOException {

    JspWriter out = getJspContext().getOut();
    out.println("<h3>" + getDisplayTitle() + "</h3>");

    if (displayType.equals("multiSelect")) {
        doMultiSelect(out);/*from  www. ja  va2s  . c  om*/
    } else if (displayType.equals("sliderRange")) {
        doSliderRange(out);
    }
    super.doTag();
}

From source file:org.kuali.mobility.writer.tags.ArticleImageTag.java

/**
 * To view the full size image of the article we will use the child browser cordova plugin
 * if we are native. This is handy especially when busy editing an article where we can not
 * navigate to another page - the changed being edited will be lost.
 *
 * @param out         JSP Writer output//from  ww  w .  j  a v a2s. com
 * @param previewPath Path to the image preview
 * @throws IOException Thrown when the JspWriter throws an exception
 */
private void writeChildBrowserJS(JspWriter out, String previewPath) throws IOException {
    out.println("<script>");
    out.println("$(document).ready(function(){");
    out.println("   $(\"#previewLink" + id + "\").click(function(){");
    out.println("      window.plugins.childBrowser.onLocationChange = function(loc){");
    out.println("         if (loc.indexOf(\"close\") > 0){");
    out.println("            window.plugins.childBrowser.close();");
    out.println("         }");
    out.println("      };");
    out.println("      window.plugins.childBrowser.showWebPage(\"" + previewPath
            + "\",{showLocationBar: false });");
    out.println("   });");
    out.println("});");
    out.println("</script>");
    out.println("<a id=\"previewLink" + id + "\" href=\"#\" />");
}

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

@Override
public int doEndTag() throws JspException {
    final JspWriter out = pageContext.getOut();

    try {//w ww . j  a  v a  2 s.com
        if (!(items instanceof Page<?>)) {
            out.println("<!-- pagination tag: items is not a page -->");
            return EVAL_PAGE;
        }
        out.println("<span style='vertical-align:middle'>");
        final Page<?> page = (Page<?>) items;
        final HttpServletRequest request = (HttpServletRequest) pageContext.getRequest();

        final int currentPage = page.getCurrentPage() + 1;
        final int pageCount = page.getPageCount();

        if (!page.isEmpty()) {
            final MessageHelper messageHelper = SpringHelper.bean(pageContext.getServletContext(),
                    MessageHelper.class);
            if (pageCount == 1) {
                out.println(messageHelper.message("global.pagination.single.page", page.getTotalCount()));
            } else {
                out.println(messageHelper.message("global.pagination.various.pages", page.getTotalCount()));
                if (currentPage > 1) {
                    out.println(pageLink(currentPage - 1, "<img src=\"" + request.getContextPath()
                            + "/pages/images/previous.gif\" style=\"valign:bottom\" border=\"0\" title=\""
                            + messageHelper.message("global.pagination.tooltip.previous") + "\">"));
                }
                out.println(StringUtils.join(resolvePages(currentPage, pageCount), ' '));
                if (currentPage < pageCount) {
                    out.println(pageLink(currentPage + 1,
                            "<img src=\"" + request.getContextPath()
                                    + "/pages/images/next.gif\" style=\"valign:bottom\" border=\"0\" title=\""
                                    + messageHelper.message("global.pagination.tooltip.next") + "\">"));
                }
            }
        }
        out.println("</span>");
        return EVAL_PAGE;
    } catch (final IOException e) {
        throw new JspException(e);
    } finally {
        release();
    }

}

From source file:org.openmrs.module.mdrtb.web.taglib.ModalDialogTag.java

/**
 * @see Tag#doStartTag()//from ww w. j  av  a 2 s  .  c  o m
 */
public int doStartTag() throws JspException {
    StringBuilder sb = new StringBuilder();
    sb.append("<script type=\"text/javascript\">");
    sb.append("   $j(document).ready(function(){");
    sb.append("      $j('#" + targetId + "').dialog({");
    sb.append("         modal: " + ObjectUtil.nvl(modal, true) + ",");
    sb.append("         autoOpen: " + ObjectUtil.nvl(autoOpen, false) + ",");
    sb.append("         draggable: " + ObjectUtil.nvl(draggable, false) + ",");
    sb.append("         resizable: " + ObjectUtil.nvl(resizable, false) + ",");
    sb.append("         closeOnEscape: " + ObjectUtil.nvl(closeOnEscape, false) + ",");
    sb.append("         width: '" + ObjectUtil.nvl(width, "90%") + "',");
    sb.append("         height: " + ObjectUtil.nvlStr(height, "$j(window).height()-50") + ",");
    sb.append("         position:  '" + ObjectUtil.nvlStr(position, "top") + "',");
    sb.append("         zIndex: " + ObjectUtil.nvlStr(zIndex, 100) + ",");
    sb.append("         title: '" + ObjectUtil.nvlStr(title, "") + "'");
    sb.append("      });");
    if (ObjectUtil.notNull(sourceId)) {
        sb.append("$j('#" + sourceId + "')." + ObjectUtil.nvlStr(event, "click") + "(function(event){");
        sb.append("      $j('#" + targetId + "').dialog('open');");
        sb.append("});");
    }
    sb.append("});");
    sb.append("</script>");

    try {
        JspWriter w = pageContext.getOut();
        w.println(sb);
    } catch (IOException ex) {
        log.error("Error while starting duration tag", ex);
    }
    return SKIP_BODY;
}

From source file:info.magnolia.cms.gui.inline.ButtonEdit.java

/**
 * <p>//from ww w. ja  v  a 2  s  . c  o  m
 * draws the edit button
 * </p>
 * <p>
 * request has to be set!
 * </p>
 */
public void drawHtml(JspWriter out) throws IOException {
    if (this.getRequest() != null) {
        boolean isGranted = Resource.getActivePage(this.getRequest()).isGranted(Permission.SET);
        if (!Resource.showPreview(this.getRequest()) && isGranted) {
            out.println(this.getHtml());
        }
    }
}

From source file:gov.nih.nci.cadsr.cdecurate.tool.tags.CreateMenuTag.java

public int doEndTag() throws JspException {
    JspWriter createMenu = this.pageContext.getOut();
    HttpSession session = pageContext.getSession();
    String userName = null;/*from   w w w  . j  a v a 2 s .  c  o  m*/
    if (session != null) {
        userName = (String) session.getAttribute("Username");
    }
    try {
        createMenu
                .println(
                        "<dl class=\"menu\">"
                                + generateDT("",
                                        "displayStepsToFollow('" + StringEscapeUtils.escapeJavaScript(userName)
                                                + "')",
                                        "New Using Existing")
                                + generateDT(
                                        "", "displayStepsToFollow2('"
                                                + StringEscapeUtils.escapeJavaScript(userName) + "')",
                                        "New Version")
                                + separator()
                                //+generateDT("","callCCNew('"+StringEscapeUtils.escapeJavaScript(userName)+"')","Concept Class")
                                + generateDT("",
                                        "callDENew('" + StringEscapeUtils.escapeJavaScript(userName) + "')",
                                        "Data Element")
                                + generateDT("",
                                        "callDECNew('" + StringEscapeUtils.escapeJavaScript(userName) + "')",
                                        "Data Element Concept")
                                + generateDT("",
                                        "callVDNew('" + StringEscapeUtils.escapeJavaScript(userName) + "')",
                                        "Value Domain")
                                + "</dl>");
        createMenu.println(generateForm("newDEForm", "../../cdecurate/NCICurationServlet?reqType=newDEFromMenu")
                + generateForm("newDECForm", "../../cdecurate/NCICurationServlet?reqType=newDECFromMenu")
                + generateForm("newVDForm", "../../cdecurate/NCICurationServlet?reqType=newVDFromMenu")
                + generateForm("newCCForm", "../../cdecurate/NCICurationServlet?reqType=newCCFromMenu"));
    } catch (IOException e) {
        e.printStackTrace();
    }

    return EVAL_PAGE;
}

From source file:de.u808.simpleinquest.web.tags.HitsNavigationTag.java

public void doTag() throws JspException {
    PageContext pageContext = (PageContext) getJspContext();
    JspWriter out = pageContext.getOut();
    try {//from w  w  w .  j a va2  s.  co m
        boolean isFirstPage = search.getPageIndex() == 0;
        boolean isLastPage = search.getPageIndex() == search.getPageCount() - 1;
        if (!isFirstPage) {
            out.println("<a href=\"search.htm?searchString=" + search.getSearchString() + "&pageIndex=0\"> ");
        }
        out.println("<img src=\"/SimpleInquest/img/start.gif\" alt=\"Erste Seite\"/>");
        if (!isFirstPage) {
            out.println("</a>");
            out.println("<a href=\"search.htm?searchString=" + search.getSearchString() + "&pageIndex="
                    + (search.getPageIndex() - 1) + "\"> ");
        }
        out.println("<img src=\"/SimpleInquest/img/left.gif\" alt=\"Vorherige Seite\"/>");
        if (!isFirstPage) {
            out.println("</a>");
        }
        for (int i = 0; i < search.getPageCount(); i++) {
            if (i != search.getPageIndex()) {
                out.println("<a href=\"search.htm?searchString=" + search.getSearchString() + "&pageIndex=" + i
                        + "\"> " + (i + 1) + "</a>");
            } else {
                out.print(i + 1);
            }
        }
        if (!isLastPage) {
            out.println("<a href=\"search.htm?searchString=" + search.getSearchString() + "&pageIndex="
                    + (search.getPageIndex() + 1) + "\"> ");
        }
        out.println("<img src=\"/SimpleInquest/img/right.gif\" alt=\"Folgende Seite\"/>");
        if (!isLastPage) {
            out.println("</a>");
            out.println("<a href=\"search.htm?searchString=" + search.getSearchString() + "&pageIndex="
                    + (search.getPageCount() - 1) + "\"> ");
        }
        out.println("<img src=\"/SimpleInquest/img/end.gif\" alt=\"Letzte Seite\"/>");
        if (!isLastPage) {
            out.println("</a>");
        }
    } catch (Exception e) {
        log.error("Tag error", e);
    }

}