List of usage examples for javax.servlet.jsp JspWriter print
abstract public void print(Object obj) throws IOException;
From source file:edu.cornell.mannlib.vitro.webapp.web.jsptags.OptionsForClassTag.java
public int doStartTag() { try {/*from w w w. j a va 2s.c o m*/ VitroRequest vreq = new VitroRequest((HttpServletRequest) pageContext.getRequest()); WebappDaoFactory wdf = vreq.getWebappDaoFactory(); if (wdf == null) throw new Exception("could not get WebappDaoFactory from request."); VClass vclass = wdf.getVClassDao().getVClassByURI(getClassUri()); if (vclass == null) throw new Exception("could not get class for " + getClassUri()); List<Individual> individuals = wdf.getIndividualDao().getIndividualsByVClassURI(vclass.getURI(), -1, -1); JspWriter out = pageContext.getOut(); for (Individual ind : individuals) { String uri = ind.getURI(); if (uri != null) { out.print("<option value=\"" + StringEscapeUtils.escapeHtml(uri) + '"'); if (uri.equals(getSelectedUri())) out.print(" selected=\"selected\""); out.print('>'); out.print(StringEscapeUtils.escapeHtml(ind.getName())); out.println("</option>"); } } } catch (Exception ex) { throw new Error("Error in doStartTag: " + ex.getMessage()); } return SKIP_BODY; }
From source file:info.magnolia.cms.taglibs.util.FileSrc.java
private void writeSrc(String src) { JspWriter out = pageContext.getOut(); try {//from w w w . j a va 2 s. c om out.print(src); } catch (Exception e) { if (log.isDebugEnabled()) log.debug("Exception caught: " + e.getMessage(), e); //$NON-NLS-1$ } }
From source file:com.googlecode.psiprobe.jsp.VisualScoreTag.java
public int doAfterBody() throws JspException { BodyContent bc = getBodyContent();/*from w ww .ja v a 2s . c om*/ String body = bc.getString().trim(); StringBuffer buf = calculateSuffix(body); try { JspWriter out = bc.getEnclosingWriter(); out.print(buf.toString()); } catch (IOException ioe) { throw new JspException("Error:IOException while writing to client" + ioe.getMessage()); } return SKIP_BODY; }
From source file:ch.entwine.weblounge.taglib.content.ActionTag.java
/** * This method is called after the action tag body has been evaluated. Like * this, the action parameters had the chance to tell us about parameters. * /*from w ww.ja va 2s . co m*/ * @see javax.servlet.jsp.tagext.Tag#doEndTag() */ public int doEndTag() throws JspException { try { if (action == null) return EVAL_PAGE; // Add cache tags response.addTag(CacheTag.Module, action.getModule().getIdentifier()); response.addTag(CacheTag.Action, action.getIdentifier()); StringBuffer a = new StringBuffer("<a "); if (getId() != null) a.append("id=\"" + getId() + "\""); a.append("href=\""); a.append(StringEscapeUtils.escapeXml(action.getPath())); // Add target url if present StringBuffer params = new StringBuffer(""); // Add other parameters Iterator<String> pi = parameters.keySet().iterator(); while (pi.hasNext()) { String param = pi.next(); String value = URLEncoder.encode(parameters.get(param), "utf-8"); params.append((params.length() == 0 ? "?" : "&") + param + "=" + value); } a.append(StringEscapeUtils.escapeXml(params.toString())); a.append("\""); if (target != null) { a.append(" target=\""); a.append(StringEscapeUtils.escapeXml(target)); a.append("\""); } a.append(">"); if (body != null) { a.append(body.trim()); } a.append("</a>"); JspWriter out = pageContext.getOut(); out.print(a.toString()); } catch (IOException e) { logger.warn("Error when writing action tag: " + e.getMessage()); } return super.doEndTag(); }
From source file:com.feilong.taglib.util.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. * * @param pageContext/*from w w w. ja v a2s .com*/ * The PageContext object for this page * @param text * The text to be written * @throws UncheckedIOException * the unchecked io exception */ public void write(PageContext pageContext, String text) throws UncheckedIOException { JspWriter writer = pageContext.getOut(); try { writer.print(text); } catch (IOException e) { throw new UncheckedIOException(e); } }
From source file:org.dspace.app.webui.jsptag.SelectGroupTag.java
public int doStartTag() throws JspException { try {/*from w ww .ja va 2s .c o m*/ JspWriter out = pageContext.getOut(); HttpServletRequest req = (HttpServletRequest) pageContext.getRequest(); out.print( "<table><tr><td colspan=\"2\" align=\"center\"><select multiple=\"multiple\" name=\"group_ids\" size=\""); out.print(multiple ? "10" : "1"); out.println("\">"); //ensure that if no group is selected that a blank option is displayed - xhtml compliance if (groups == null || groups.length == 0) { out.print("<option value=\"\"> </option>"); } if (groups != null) { for (int i = 0; i < groups.length; i++) { out.print("<option value=\"" + groups[i].getID() + "\">"); out.print(groups[i].getName() + " (" + groups[i].getID() + ")"); out.println("</option>"); } } out.print("</select></td>"); if (multiple) { out.print("</tr><tr><td width=\"50%\" align=\"center\">"); } else { out.print("<td>"); } String p = (multiple ? LocaleSupport.getLocalizedMessage(pageContext, "org.dspace.app.webui.jsptag.SelectGroupTag.selectGroups") : LocaleSupport.getLocalizedMessage(pageContext, "org.dspace.app.webui.jsptag.SelectGroupTag.selectGroup")); out.print("<input type=\"button\" value=\"" + p + "\" onclick=\"javascript:popup_window('" + req.getContextPath() + "/tools/group-select-list?multiple=" + multiple + "', 'group_popup');\" />"); if (multiple) { out.print("</td><td width=\"50%\" align=\"center\">"); out.print("<input type=\"button\" value=\"" + LocaleSupport.getLocalizedMessage(pageContext, "org.dspace.app.webui.jsptag.SelectGroupTag.removeSelected") + "\" onclick=\"javascript:removeSelected(window.document.epersongroup.group_ids);\"/>"); } out.println("</td></tr></table>"); } catch (IOException ie) { throw new JspException(ie); } return SKIP_BODY; }
From source file:org.dspace.app.webui.jsptag.SelectEPersonTag.java
public int doStartTag() throws JspException { try {// w ww . j av a 2 s .c om JspWriter out = pageContext.getOut(); HttpServletRequest req = (HttpServletRequest) pageContext.getRequest(); out.print( "<table><tr><td colspan=\"2\" align=\"center\"><select multiple=\"multiple\" name=\"eperson_id\" size=\""); out.print(multiple ? "10" : "1"); out.println("\">"); // ensure that if no eperson is selected that a blank option is displayed - xhtml compliance if (epeople == null || epeople.length == 0) { out.print("<option value=\"\"> </option>"); } if (epeople != null) { for (int i = 0; i < epeople.length; i++) { out.print("<option value=\"" + epeople[i].getID() + "\">"); out.print(epeople[i].getFullName() + " (" + epeople[i].getEmail() + ")"); out.println("</option>"); } } // add blank option value if no person selected to ensure that code is xhtml compliant //out.print("<option/>"); out.print("</select></td>"); if (multiple) { out.print("</tr><tr><td width=\"50%\" align=\"center\">"); } else { out.print("<td>"); } String p = (multiple ? LocaleSupport.getLocalizedMessage(pageContext, "org.dspace.app.webui.jsptag.SelectEPersonTag.selectPeople") : LocaleSupport.getLocalizedMessage(pageContext, "org.dspace.app.webui.jsptag.SelectEPersonTag.selectPerson")); out.print("<input type=\"button\" value=\"" + p + "\" onclick=\"javascript:popup_window('" + req.getContextPath() + "/tools/eperson-list?multiple=" + multiple + "', 'eperson_popup');\" />"); if (multiple) { out.print("</td><td width=\"50%\" align=\"center\">"); out.print("<input type=\"button\" value=\"" + LocaleSupport.getLocalizedMessage(pageContext, "org.dspace.app.webui.jsptag.SelectEPersonTag.removeSelected") + "\" onclick=\"javascript:removeSelected(window.document.epersongroup.eperson_id);\"/>"); } out.println("</td></tr></table>"); } catch (IOException ie) { throw new JspException(ie); } return SKIP_BODY; }
From source file:org.dspace.app.webui.jsptag.CommunityListTag.java
public int doStartTag() throws JspException { JspWriter out = pageContext.getOut(); try {/*from ww w.j av a 2 s .co m*/ out.println("<table align=\"center\" class=\"miscTable\" title=\"Community List\">"); // Write column headings out.print("<tr><th id=\"t5\" class=\"oddRowOddCol\">" + LocaleSupport.getLocalizedMessage(pageContext, "org.dspace.app.webui.jsptag.CommunityListTag.communityName") + "</th></tr>"); // Row: toggles between Odd and Even String row = "even"; for (int i = 0; i < communities.length; i++) { // name String name = communities[i].getMetadata("name"); // first and only column is 'name' out.print("<tr><td headers=\"t5\" class=\"" + row + "RowEvenCol\">"); out.print("<a href=\""); HttpServletRequest hrq = (HttpServletRequest) pageContext.getRequest(); out.print(hrq.getContextPath() + "/handle/"); out.print(communities[i].getHandle()); out.print("\">"); out.print(name); out.print("</a>"); out.println("</td></tr>"); row = (row.equals("odd") ? "even" : "odd"); } out.println("</table>"); } catch (IOException ie) { throw new JspException(ie); } return SKIP_BODY; }
From source file:org.dspace.app.webui.jsptag.CollectionListTag.java
public int doStartTag() throws JspException { JspWriter out = pageContext.getOut(); try {//w w w .j a v a2s . c o m out.println("<table align=\"center\" class=\"miscTable\" title=\"Collection List\">"); // Write column headings out.print("<tr><th id=\"t4\" class=\"oddRowOddCol\">" + LocaleSupport.getLocalizedMessage(pageContext, "org.dspace.app.webui.jsptag.CollectionListTag.collectionName") + "</th></tr>"); // Row: toggles between Odd and Even String row = "even"; for (int i = 0; i < collections.length; i++) { // name String name = collections[i].getMetadata("name"); // first and only column is 'name' out.print("<tr><td headers=\"t4\" class=\"" + row + "RowEvenCol\">"); out.print("<a href=\""); HttpServletRequest hrq = (HttpServletRequest) pageContext.getRequest(); out.print(hrq.getContextPath() + "/handle/"); out.print(collections[i].getHandle()); out.print("\">"); out.print(name); out.print("</a>"); out.println("</td></tr>"); row = (row.equals("odd") ? "even" : "odd"); } out.println("</table>"); } catch (IOException ie) { throw new JspException(ie); } return SKIP_BODY; }
From source file:org.jahia.taglibs.internal.gwt.GWTInitTag.java
/** * Create a javascript object that//from w ww. j ava 2 s. c o m * contains some jahia parameters in order to use the Google Web Toolkit.<br> * Usage example inside a JSP:<br> * <!-- * <%@ page language="java" contentType="text/html;charset=UTF-8" %> * <html> * <head> * <ajax:initGWT/> * </head> * --> * ... * * @return SKIP_BODY */ public int doStartTag() { try { final JspWriter out = pageContext.getOut(); final HttpServletRequest request = (HttpServletRequest) pageContext.getRequest(); final HttpSession session = request.getSession(); out.print(GWTInitializer.generateInitializerStructure(request, session, StringUtils.isEmpty(locale) ? null : LanguageCodeConverters.languageCodeToLocale(locale), StringUtils.isEmpty(uilocale) ? null : LanguageCodeConverters.languageCodeToLocale(uilocale))); } catch (IOException e) { logger.error(e.getMessage(), e); } return SKIP_BODY; }