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:org.opencms.setup.CmsUpdateBean.java

/**
 * Generates the output for the update wizard.<p>
 * //w  w  w . ja  v a 2s.co  m
 * @param out the JSP print stream
 * 
 * @throws IOException in case errors occur while writing to "out"
 */
public void prepareUpdateStep5bOutput(JspWriter out) throws IOException {

    if ((m_workplaceUpdateThread == null) || (m_workplaceUpdateThread.getLoggingThread() == null)) {
        return;
    }
    m_oldLoggingOffset = m_newLoggingOffset;
    m_newLoggingOffset = m_workplaceUpdateThread.getLoggingThread().getMessages().size();
    if (isInitialized()) {
        for (int i = m_oldLoggingOffset; i < m_newLoggingOffset; i++) {
            String str = m_workplaceUpdateThread.getLoggingThread().getMessages().get(i).toString();
            str = CmsEncoder.escapeWBlanks(str, CmsEncoder.ENCODING_UTF_8);
            out.println("output[" + (i - m_oldLoggingOffset) + "] = \"" + str + "\";");
        }
    } else {
        out.println("output[0] = 'ERROR';");
    }

    boolean threadFinished = m_workplaceUpdateThread.isFinished();
    boolean allWritten = m_oldLoggingOffset >= m_workplaceUpdateThread.getLoggingThread().getMessages().size();

    out.println("function initThread() {");
    if (isInitialized()) {
        out.print("send();");
        if (threadFinished && allWritten) {
            out.println("setTimeout('top.display.finish()', 500);");
        } else {
            int timeout = 5000;
            if (getWorkplaceUpdateThread().getLoggingThread().getMessages().size() < 20) {
                timeout = 1000;
            }
            out.println("setTimeout('location.reload()', " + timeout + ");");
        }
    }
    out.println("}");
}

From source file:gov.nih.nci.rembrandt.web.taglib.HCPlotReport.java

public int doStartTag() {
    try {//w ww.  ja  v  a  2 s .  com
        JspWriter out = pageContext.getOut();
        ServletRequest request = pageContext.getRequest();
        HttpSession session = pageContext.getSession();
        StringBuffer xhtml = new StringBuffer();
        if (taskId != null) {

            hcaFinding = (HCAFinding) businessTierCache.getSessionFinding(session.getId(), taskId);
            List<String> clusterByIds = new ArrayList();
            //ok, what did we cluster by?...can only be 1
            if (hcaFinding != null) {
                HierarchicalClusteringQueryDTO hcQueryDTO = (HierarchicalClusteringQueryDTO) hcaFinding
                        .getQueryDTO();
                ArrayPlatformType arrayPlatform = hcQueryDTO.getArrayPlatformDE() != null
                        ? hcQueryDTO.getArrayPlatformDE().getValueObjectAsArrayPlatformType()
                        : ArrayPlatformType.AFFY_OLIGO_PLATFORM;
                if (hcaFinding.getClusteredReporterIDs() != null
                        && hcaFinding.getClusteredReporterIDs().size() > 0) {
                    clusterByIds = (List) hcaFinding.getClusteredReporterIDs();
                    xhtml.append(quickReporterReport(clusterByIds, arrayPlatform));
                } else if (hcaFinding.getClusteredSampleIDs() != null
                        && hcaFinding.getClusteredSampleIDs().size() > 0) {
                    clusterByIds = (List) hcaFinding.getClusteredSampleIDs();
                    xhtml.append(quickSampleReport(clusterByIds));
                }
            }

            out.println(xhtml.toString());
        } else {
            out.println("No Report Available.");
        }
    } catch (Exception ex) {
        throw new Error("All is not well in the world.");
    }
    // Must return SKIP_BODY because we are not supporting a body for this tag.
    return SKIP_BODY;
}

From source file:jp.terasoluna.fw.web.struts.taglib.PageLinksTag.java

/**
 * ^O]Jn?\bh?B/*from  w ww  . j av  a2  s. c  o  m*/
 *
 * @return ???w
 * @throws JspException JSPO
 */
@Override
public int doStartTag() throws JspException {

    //?`FbN
    if (!submit && (action == null || "".equals(action))) {
        log.error(ERROR_MESSAGE_ACTION_REQUIRED);
        throw new JspException(ERROR_MESSAGE_ACTION_REQUIRED);
    }

    // v?peBt@Cy?[WWvpN^O?
    getLinkProperty();

    //\?s?
    Object objRow = lookup(pageContext, name, rowProperty, scope);
    int row = getInt(objRow);

    //\?s?0?????I?B
    if (row <= 0) {
        if (log.isWarnEnabled()) {
            log.warn(WARN_MESSAGE_ILLEGAL_ROW);
        }
        return EVAL_BODY_INCLUDE;
    }

    //Jn?sCfbNX
    Object objIndex = lookup(pageContext, name, indexProperty, scope);
    int startIndex = getInt(objIndex);

    //S??
    Object objTotal = lookup(pageContext, name, totalProperty, scope);
    int totalCount = getInt(objTotal);

    //StringBuilder??
    StringBuilder sb = new StringBuilder();

    //?y?[W??A?y?[W???B
    attributePageCount(getPageIndex(row, startIndex), getPageCount(row, totalCount));

    if (submit) {
        //submit?true?ATu~bg?sy?[WN?o?B

        //\?s??AJnCfbNX^O?o
        defineHtml(row, startIndex, totalCount);

        //Oy?[WN?
        addPrevSubmit(sb, row, startIndex, totalCount);

        //y?[W?N?
        addDirectSubmit(sb, row, startIndex, totalCount);

        //y?[WN?
        addNextSubmit(sb, row, startIndex, totalCount);

    } else {
        //submit?false??

        //Oy?[WN?
        addPrevLink(sb, row, startIndex, totalCount);

        //y?[W?N?
        addDirectLink(sb, row, startIndex, totalCount);

        //y?[WN?
        addNextLink(sb, row, startIndex, totalCount);
    }

    //StringBuildere?o?B
    if (id == null || "".equals(id)) {
        try {
            JspWriter writer = pageContext.getOut();
            writer.println(sb.toString());
        } catch (IOException e) {
            log.error(e.getMessage());
            throw new JspTagException(e.toString());
        }
    } else {
        pageContext.setAttribute(id, sb.toString());
    }

    return EVAL_BODY_INCLUDE;
}

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

/**
 * List links to collections if information is available
 */// w  ww .ja  v  a 2 s . c  o m
private void listCollections() throws IOException {
    JspWriter out = pageContext.getOut();
    HttpServletRequest request = (HttpServletRequest) pageContext.getRequest();

    if (collections != null) {
        out.print("<tr><td class=\"metadataFieldLabel\">");
        if (item.getHandle() == null) // assume workspace item
        {
            out.print(LocaleSupport.getLocalizedMessage(pageContext,
                    "org.dspace.app.webui.jsptag.ItemTag.submitted"));
        } else {
            out.print(LocaleSupport.getLocalizedMessage(pageContext,
                    "org.dspace.app.webui.jsptag.ItemTag.appears"));
        }
        out.print("</td><td class=\"metadataFieldValue\">");

        for (int i = 0; i < collections.length; i++) {
            out.print("<a href=\"");
            out.print(request.getContextPath());
            out.print("/handle/");
            out.print(collections[i].getHandle());
            out.print("\">");
            out.print(collections[i].getMetadata("name"));
            out.print("</a><br/>");
        }

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

From source file:org.disit.servicemap.api.ServiceMapApi.java

public void queryLocation(JspWriter out, RepositoryConnection con, String lat, String lng) throws Exception {
    JSONObject obj = queryLocation(con, lat, lng);
    if (obj != null)
        out.print(obj.toString());/*from   w w w  .  ja  v a2  s .c om*/
    else
        out.println("{}");
}

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

/**
 * Generate the initial assignment of the global variables for editing a
 * team's score./*from  w w  w.j av  a2  s  . co  m*/
 */
public static void generateInitForScoreEdit(final JspWriter writer, final ServletContext application,
        final HttpSession session) throws SQLException, IOException {
    final ChallengeDescription description = ApplicationAttributes.getChallengeDescription(application);
    final int teamNumber = SessionAttributes.getNonNullAttribute(session, "team", Team.class).getTeamNumber();
    final int runNumber = SessionAttributes.getNonNullAttribute(session, "lRunNumber", Number.class).intValue();

    final DataSource datasource = ApplicationAttributes.getDataSource(application);

    PreparedStatement prep = null;
    ResultSet rs = null;
    Connection connection = null;
    try {
        connection = datasource.getConnection();
        final int tournament = Queries.getCurrentTournament(connection);

        prep = connection.prepareStatement("SELECT * from Performance" + " WHERE TeamNumber = ?" //
                + " AND RunNumber = ?"//
                + " AND Tournament = ?");
        prep.setInt(1, teamNumber);
        prep.setInt(2, runNumber);
        prep.setInt(3, tournament);

        rs = prep.executeQuery();
        if (rs.next()) {
            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 String rawVarName = getVarNameForRawScore(name);

                    if (goal.isEnumerated()) {
                        // enumerated
                        final String storedValue = rs.getString(name);
                        boolean found = false;
                        for (final EnumeratedValue valueElement : goal.getSortedValues()) {
                            final String value = valueElement.getValue();
                            if (value.equals(storedValue)) {
                                writer.println("  " + rawVarName + " = \"" + value + "\";");
                                found = true;
                            }
                        }
                        if (!found) {
                            throw new RuntimeException(
                                    "Found enumerated value in the database that's not in the XML document, goal: "
                                            + name + " value: " + storedValue);
                        }
                    } else {
                        // just use the value that is stored in the database
                        writer.println("  " + rawVarName + " = " + rs.getString(name) + ";");
                    }
                } // !computed
            } // foreach goal
              // Always init the special double-check column
            writer.println("  Verified = " + rs.getBoolean("Verified") + ";");
        } else {
            throw new RuntimeException("Cannot find TeamNumber and RunNumber in Performance table"
                    + " TeamNumber: " + teamNumber + " RunNumber: " + runNumber);
        }
    } finally {
        SQLFunctions.close(rs);
        SQLFunctions.close(prep);
        SQLFunctions.close(connection);
    }
}

From source file:jp.terasoluna.fw.web.struts.taglib.PageLinksTag.java

/**
 * HTML`?o?B//  w  w w.  j av a2s  . c  o  m
 * 
 * @param row \?s?
 * @param startIndex \JnCfbNX
 * @param totalCount S??
 * @throws JspException JSPO
 */
protected void defineHtml(int row, int startIndex, int totalCount) throws JspException {

    JspWriter writer = pageContext.getOut();
    try {

        //OHidden^O?o?AtOm?B
        if (!getPageContextFlg(pageContext, PAGELINKS_JAVASCRIPT_KEY + rowProperty)) {

            //\??Hidden^O
            writer.println("<input type=\"hidden\" name=\"" + rowProperty + "\" value=\"" + row + "\"/>");

            //?otO?B
            setPageContextFlg(pageContext, PAGELINKS_JAVASCRIPT_KEY + rowProperty);
        }

        //OHidden^O?o?AtOm?B
        if (!getPageContextFlg(pageContext, PAGELINKS_JAVASCRIPT_KEY + indexProperty)) {

            //\JnCfbNXHidden^O
            writer.println(
                    "<input type=\"hidden\" name=\"" + indexProperty + "\" value=\"" + startIndex + "\"/>");

            //?otO?B
            setPageContextFlg(pageContext, PAGELINKS_JAVASCRIPT_KEY + indexProperty);
        }

        //OHidden^O?o?AtOm?B
        if (!getPageContextFlg(pageContext, PAGELINKS_JAVASCRIPT_KEY + event) && forward) {

            //\JnCfbNXHidden^O
            writer.println("<input type=\"hidden\" name=\"" + event + "\" value=\"\"/>");

            //?otO?B
            setPageContextFlg(pageContext, PAGELINKS_JAVASCRIPT_KEY + event);
        }

        //OHidden^O?o?AtOm?B
        if (!getPageContextFlg(pageContext, PAGELINKS_JAVASCRIPT_KEY + "resetIndex") && resetIndex) {

            //startIndexHidden^O
            if (!"startIndex".equals(indexProperty)) {
                writer.println(
                        "<input type=\"hidden\" name=\"" + "startIndex\" value=\"" + startIndex + "\"/>");
            }

            //endIndexHidden^O
            int endIndex = startIndex + row - 1;
            if (endIndex >= totalCount) {
                writer.println(
                        "<input type=\"hidden\" name=\"" + "endIndex\" value=\"" + (totalCount - 1) + "\"/>");
            } else {
                writer.println("<input type=\"hidden\" name=\"" + "endIndex\" value=\"" + endIndex + "\"/>");
            }

            //?otO?B
            setPageContextFlg(pageContext, PAGELINKS_JAVASCRIPT_KEY + "resetIndex");
        }

        //tH?[
        String formName = ActionFormUtil.getActionFormName((HttpServletRequest) pageContext.getRequest());

        //Tu~bg?sJavaScript?B
        //?Ay?[WN^O?L?q??P
        if (!getPageContextFlg(pageContext, PAGELINKS_JAVASCRIPT_KEY)) {
            writer.println("<script type=\"text/javascript\">");
            writer.println("<!--");
            writer.println("  function pageLinkSubmit(rowObj, indexObj," + " row, startIndex){");
            writer.println("    rowObj.value = row;");
            writer.println("    indexObj.value = startIndex;");

            //forward?true???Aevent?Hidden^O
            //p??[^??B
            if (forward) {
                writer.print("    document.");
                writer.print(formName);
                writer.print(".");
                writer.print(event);
                writer.print(".value = \"");
                writer.print(FORWARD_NAME);
                writer.println("\";");
            }

            writer.print("    document.");
            writer.print(formName);
            writer.println(".submit();");
            writer.println("  }");
            writer.println("// -->");
            writer.println("</script>");

            //?otO?B
            setPageContextFlg(pageContext, PAGELINKS_JAVASCRIPT_KEY);
        }

    } catch (IOException e) {
        log.error(e.getMessage());
        throw new JspTagException(e.toString());
    }
}

From source file:org.squale.welcom.taglib.progressbar.ProgressBarTag.java

public int doStartTag() throws JspException {
    JspWriter out = this.pageContext.getOut();

    try {//from  w  w  w.ja  v  a2  s .  c o  m
        // Inclusion de la librairie JS
        CanvasUtil.addJs(
                WelcomConfigurator.getMessage(WelcomConfigurator.HEADER_LOCALJS_PATH_KEY) + "progressbar.js",
                this, pageContext);

        boolean isIE = false;
        boolean isSafari = false;
        boolean isOpera = false;
        String userAgent = ((HttpServletRequest) pageContext.getRequest()).getHeader("User-Agent");

        if (userAgent != null) {
            if (userAgent.indexOf("MSIE") != -1) {
                isIE = true;
            } else {
                if (userAgent.indexOf("Safari") != -1) {
                    isSafari = true;
                } else {
                    if (userAgent.indexOf("Opera") != -1) {
                        isOpera = true;
                    }
                }
            }
        }

        String pbProperties = " wRefreshRate='" + refreshRate + "'";

        if (!GenericValidator.isBlankOrNull(onChangeHook)) {
            pbProperties += " wOnChangeHook='" + onChangeHook + "'";
        }

        if (!GenericValidator.isBlankOrNull(onCompleteHook)) {
            pbProperties += " wOnCompleteHook='" + onCompleteHook + "'";
        }

        pbProperties += " wIsFullScreen='" + isFullScreen + "'";

        out.println("<input type='hidden' id='wWatchedTaskId' name='wWatchedTaskId'>");

        out.println("<DIV id='" + id + "' " + pbProperties + ">");

        if (isFullScreen) {

            // Cration de variable pour viter de passer ces infos dans l'appel
            // JS

            if (isIE) {
                out.println("<IFRAME frameborder=0 id=wDivProgressBarBG style=\"background-color:#ffffff;");
                out.println("filter:alpha(opacity=60);");
                out.println("visibility: hidden;");
                out.println(
                        "position:absolute; top:0px; left:0px; width:1400px; height:909px; z-index:123; padding:0; border-width:0; border-style:none, margin:0;\">");
                out.println("</IFRAME>");
            } else {
                out.println("<div id=wDivProgressBarBG style=\"background-color:#ffffff;");
                out.print("-moz-opacity:0.6;");
                out.print("opacity: 0.6;");
                out.print("visibility: hidden;");
                out.print(
                        "position:absolute; top:0px; left:0px; width:100%; height:100%; z-index:123; margin:0;\">");
                out.println("</div>");
            }

            out.println("<div id=wDivProgressBar style=\"background-color:#FFFFFF;");
            out.print("position:absolute;");
            out.print("left:50%;");
            out.print("top:50%;");
            out.print("visibility: hidden;");
            out.print("margin-left:-50px;");
            out.print("margin-top:-50px; ");
            out.print("z-index:124;");
            out.print("border:1px solid #888\">");
        } // Fin IF isFullScreen

        // Cration de la zone d'affichage
        String tdStatus;
        if (showStatusText) {
            tdStatus = "<span style=\"color:#000\" id='" + getId() + "_status'>-</span>";
        } else {
            tdStatus = "";
        }

        String tdPct;
        if (showPctText) {
            tdPct = "<span style=\"color:#000\" id=\"" + getId() + "_pctText\">0%</span>";
        } else {
            tdPct = "";
        }

        boolean leftExists = false;
        boolean topExists = false;
        boolean rightExists = false;
        boolean bottomExists = false;
        boolean progressSolo = true;

        if (showPctText || showStatusText) {
            if ((pctTextPosition.equals(POS_LEFT)) || (statusTextPosition.equals(POS_LEFT))) {
                leftExists = true;
                progressSolo = false;
            }

            if ((pctTextPosition.equals(POS_TOP)) || (statusTextPosition.equals(POS_TOP))) {
                topExists = true;
                progressSolo = false;
            }

            if ((pctTextPosition.equals(POS_RIGHT)) || (statusTextPosition.equals(POS_RIGHT))) {
                rightExists = true;
                progressSolo = false;
            }

            if ((pctTextPosition.equals(POS_BOTTOM)) || (statusTextPosition.equals(POS_BOTTOM))) {
                bottomExists = true;
                progressSolo = false;
            }
        }

        if (isSafari) {
            progressSolo = true;
            bottomExists = false;
            topExists = false;
            leftExists = false;
            rightExists = false;
        }

        if (isFullScreen()) {
            out.println(
                    "<div style=\"background-image:url(theme/charte_v03_001/img/lignage/lignage_trans.gif);background-position:left bottom;background-repeat:repeat-x;height:32px;width:"
                            + width
                            + "px;\" class=\"bg_theme\"><div style=\"margin: 0pt; padding: 0px 5px; font-family: Verdana,Arial,Helvetica,sans-serif; font-weight: bold; font-size: 10px; color: rgb(255, 255, 255); background-color: rgb(5, 16, 57); cursor: default; height: 16px; float: left;\">Execution</div></div>");
        }

        // out.println("<div>");
        out.println("<table border=\"0\" cellspacing=\"2px\" style=\"0px 3px 3px 3px\" width=\"" + width
                + "px\" >");

        // Formattage
        out.print("<tr>");
        if (leftExists) {
            out.print("<th style='width: 15%'></th>");
        }

        if (!progressSolo) {
            if (leftExists && rightExists) {
                out.print("<th style='width: 70%'></th>");
            } else {
                if (leftExists || rightExists) {
                    out.print("<th style='width: 85%'></th>");
                } else {
                    out.print("<th style='width: 100%'></th>");
                }

            }
        }

        if (rightExists) {
            out.print("<th style='width: 15%'></th>");
        }

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

        // ###############
        // LIGNE du haut
        // ###############

        if (topExists) {
            out.println("<tr>");

            // ------------

            if (leftExists || rightExists) {
                out.println("<td " + STYLE_TD_NOBORDER_PADDING + " colspan=2>");
            } else {
                out.println("<td " + STYLE_TD_NOBORDER_PADDING + " >");
            }

            if (pctTextPosition.equals(POS_TOP)) {
                out.println(tdPct);
            }

            if (statusTextPosition.equals(POS_TOP)) {
                out.println(tdStatus);
            }
            out.println("</td>");

            // ------------

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

        // ###############
        // LIGNE du milieu
        // ###############
        // ------------
        out.println("<tr>");
        if (leftExists) {

            out.println("<td " + STYLE_TD_NOBORDER_PADDING + " >");
            if (pctTextPosition.equals(POS_LEFT)) {
                out.println(tdPct);
            }

            if (statusTextPosition.equals(POS_LEFT)) {
                out.println(tdStatus);
            }
            out.println("</td>");

        }
        // ------------

        out.print(" <td " + STYLE_TD_NOBORDER_PADDING + ">");

        // ----- PROGRESS BAR -----
        if (isSafari) {
            out.print(render.drawAnimatedProgressBar());
        } else {
            out.print(render.drawRealProgressBar(getId()));
        }

        // ----- PROGRESS BAR -----
        out.println("   </td>");

        // ------------
        if (rightExists) {
            out.println("<td " + STYLE_TD_NOBORDER + " >");
            if (pctTextPosition.equals(POS_RIGHT)) {
                out.println(tdPct);
            }

            if (statusTextPosition.equals(POS_RIGHT)) {
                out.println(tdStatus);
            }
            out.println("</td>");
        }

        out.println("</tr>");
        // ------------

        // ###############
        // LIGNE du bas
        // ###############
        if (bottomExists) {
            out.println("<tr>");

            // ------------

            if (leftExists || rightExists) {
                out.println("<td  " + STYLE_TD_NOBORDER_PADDING + " colspan=2>");
            } else {
                out.println("<td " + STYLE_TD_NOBORDER_PADDING + " >");
            }

            if (pctTextPosition.equals(POS_BOTTOM)) {
                out.println(tdPct);
            }

            if (statusTextPosition.equals(POS_BOTTOM)) {
                out.println(tdStatus);
            }
            out.println("</td>");

            // ------------

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

        out.println("</table>");
        // out.println("</div>");
        if (isFullScreen) {
            out.println(
                    "<div style=\"background-image:url(theme/charte_v03_001/img/lignage/footer_trans.gif);background-position:left bottom;clear:both;height:20px;width:"
                            + width + "px;\" class=\"bg_theme\"></div>");
            out.println("</div>");
        }
        out.println("</div>");
    } catch (IOException e) {
        try {
            out.println("unable to render tag due to " + e.getClass().getName() + ":" + e.getMessage());
        } catch (IOException e1) {
            // On fait rien car l'exception doit tre la mme que celle du
            // bloc catch englobant
        }
        e.printStackTrace();
    }

    // Continue processing this page
    release();
    return (EVAL_PAGE);
}

From source file:com.glaf.core.tag.SystemPageTag.java

public int doEndTag() throws JspException {
     Paging page = null;/*from  w  w w . ja  v  a 2 s .  c om*/
     if (name == null) {
         name = "glaf";
     }
     page = (Paging) pageContext.getAttribute(name);
     if (page == null) {
         page = (Paging) pageContext.getRequest().getAttribute(name);
     }
     if (page == null) {
         page = Paging.EMPTY_PAGE;
     }

     if (prefix == null) {
         prefix = "";
     }

     HttpServletRequest request = (HttpServletRequest) pageContext.getRequest();

     String complexQuery = request.getParameter("complexQuery");
     String x_complex_query = request.getParameter("x_complex_query");
     String xyz_complex_query = request.getParameter("xyz_complex_query");
     imagePath = request.getContextPath() + "/images/go.gif";
     Map<String, Object> paramMap = new java.util.HashMap<String, Object>();
     StringBuffer buffer = new StringBuffer();

     Enumeration<?> enumeration = request.getParameterNames();
     while (enumeration.hasMoreElements()) {
         String paramName = (String) enumeration.nextElement();
         String paramValue = request.getParameter(paramName);
         if (paramName.startsWith(prefix)) {
             paramName = paramName.replaceAll(prefix, "");
         }
         if (paramName.startsWith("query_")) {
             if (StringUtils.isNotEmpty(paramValue)) {
                 paramName = paramName.replaceAll("query_", "");
                 paramMap.put(paramName, paramValue);
             }
         }
     }

     Integer count = (Integer) pageContext.getRequest().getAttribute(prefix + PAGE_PART_COUNTER);
     if (count == null) {
         count = 0;
     }
     try {
         JspWriter out = pageContext.getOut();
         page.setPrefix(prefix);
         if (StringUtils.isNotEmpty(form)) {
             String suffix = "_part_" + count.intValue();
             count = count.intValue() + 1;
             if (count.intValue() == 1) {
                 if (paramMap.size() > 0) {
                     String queryString = JsonUtils.encode(paramMap);
                     if (LogUtils.isDebug()) {
                         logger.debug("query string:" + queryString);
                     }
                     queryString = RequestUtils.encodeString(queryString);
                     buffer.append(
                             "\n<input type=\"hidden\" id=\"x_complex_query\" name=\"x_complex_query\" value=\"")
                             .append(queryString).append("\">");
                 }
                 if (StringUtils.isNotEmpty(xyz_complex_query)) {
                     buffer.append(
                             "\n<input type=\"hidden\" id=\"xyz_complex_query\" name=\"xyz_complex_query\" value=\"")
                             .append(xyz_complex_query).append("\">");
                 } else {
                     if (StringUtils.isNotEmpty(x_complex_query)) {
                         buffer.append(
                                 "\n<input type=\"hidden\" id=\"xyz_complex_query\" name=\"xyz_complex_query\" value=\"")
                                 .append(x_complex_query).append("\">");
                     }
                 }
                 if (StringUtils.isNotEmpty(complexQuery)) {
                     buffer.append("\n<input type=\"hidden\" id=\"complexQuery\" name=\"complexQuery\" value=\"")
                             .append(complexQuery).append("\">");
                 }
                 out.println(this.getDefaultHiddenField(page.getCurrentPage()));
                 out.println(buffer.toString());
             }
             pageContext.getRequest().setAttribute(prefix + PAGE_PART_COUNTER, count);
             boolean showCount = true;
             if (StringUtils.equals(display, "0")) {
                 showCount = false;
             }
             String content = this.getPagingScript(page, form, suffix, showCount);
             out.println(content);
         }

     } catch (Exception ex) {
         ex.printStackTrace();
         logger.error(ex);
     }
     return EVAL_PAGE;
 }

From source file:com.glaf.core.tag.InfoPageTag.java

public int doEndTag() throws JspException {
    Paging page = null;/*w ww. j  a  v a  2 s .com*/
    if (name == null) {
        name = "glaf";
    }
    page = (Paging) pageContext.getAttribute(name);
    if (page == null) {
        page = (Paging) pageContext.getRequest().getAttribute(name);
    }
    if (page == null) {
        page = Paging.EMPTY_PAGE;
    }

    if (prefix == null) {
        prefix = "";
    }

    HttpServletRequest request = (HttpServletRequest) pageContext.getRequest();

    String complexQuery = request.getParameter("complexQuery");
    String x_complex_query = request.getParameter("x_complex_query");
    String xyz_complex_query = request.getParameter("xyz_complex_query");

    imagePath = request.getContextPath() + "/images";

    Map<String, Object> paramMap = new java.util.HashMap<String, Object>();
    StringBuffer buffer = new StringBuffer();

    Enumeration<?> enumeration = request.getParameterNames();
    while (enumeration.hasMoreElements()) {
        String paramName = (String) enumeration.nextElement();
        String paramValue = request.getParameter(paramName);
        if (paramName.startsWith(prefix)) {
            paramName = paramName.replaceAll(prefix, "");
        }
        if (paramName.startsWith("query_")) {
            if (StringUtils.isNotEmpty(paramValue)) {
                paramName = paramName.replaceAll("query_", "");
                paramMap.put(paramName, paramValue);
            }
        }
    }

    Integer count = (Integer) pageContext.getRequest().getAttribute(prefix + PAGE_PART_COUNTER);
    if (count == null) {
        count = 0;
    }
    try {
        JspWriter out = pageContext.getOut();
        page.setPrefix(prefix);
        if (StringUtils.isNotEmpty(form)) {
            String suffix = "_part_" + count.intValue();
            count = count.intValue() + 1;
            if (count.intValue() == 1) {
                if (paramMap.size() > 0) {
                    String queryString = JsonUtils.encode(paramMap);
                    if (LogUtils.isDebug()) {
                        logger.debug("query string:" + queryString);
                    }
                    queryString = RequestUtils.encodeString(queryString);
                    buffer.append(
                            "\n<input type=\"hidden\" id=\"x_complex_query\" name=\"x_complex_query\" value=\"")
                            .append(queryString).append("\">");
                }
                if (StringUtils.isNotEmpty(xyz_complex_query)) {
                    buffer.append(
                            "\n<input type=\"hidden\" id=\"xyz_complex_query\" name=\"xyz_complex_query\" value=\"")
                            .append(xyz_complex_query).append("\">");
                } else {
                    if (StringUtils.isNotEmpty(x_complex_query)) {
                        buffer.append(
                                "\n<input type=\"hidden\" id=\"xyz_complex_query\" name=\"xyz_complex_query\" value=\"")
                                .append(x_complex_query).append("\">");
                    }
                }
                if (StringUtils.isNotEmpty(complexQuery)) {
                    buffer.append("\n<input type=\"hidden\" id=\"complexQuery\" name=\"complexQuery\" value=\"")
                            .append(complexQuery).append("\">");
                }
                out.println(this.getDefaultHiddenField(page.getCurrentPage()));
                out.println(buffer.toString());
            }
            pageContext.getRequest().setAttribute(prefix + PAGE_PART_COUNTER, count);
            boolean showCount = true;
            if (StringUtils.equals(display, "0")) {
                showCount = false;
            }
            String content = this.getPagingScript(page, form, suffix, showCount);
            out.println(content);
        }

    } catch (Exception ex) {
        ex.printStackTrace();
        logger.error(ex);
    }
    return EVAL_PAGE;
}