类javax.servlet.jsp.JspWriter源码实例Demo

下面列出了怎么用javax.servlet.jsp.JspWriter的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: Tomcat8-Source-Read   文件: ValuesTag.java
@Override
public int doEndTag() throws JspException {
    JspWriter out = pageContext.getOut();

    try {
        if (!"-1".equals(objectValue)) {
            out.print(objectValue);
        } else if (!"-1".equals(stringValue)) {
            out.print(stringValue);
        } else if (longValue != -1) {
            out.print(longValue);
        } else if (doubleValue != -1) {
            out.print(doubleValue);
        } else {
            out.print("-1");
        }
    } catch (IOException ex) {
        throw new JspTagException("IOException: " + ex.toString(), ex);
    }
    return super.doEndTag();
}
 
源代码2 项目: packagedrone   文件: PageContextImpl.java
public JspWriter pushBody(Writer writer) {
       depth++;
       if (depth >= outs.length) {
           BodyContentImpl[] newOuts = new BodyContentImpl[depth + 1];
           for (int i=0; i<outs.length; i++) {
               newOuts[i] = outs[i];
           }
           newOuts[depth] = new BodyContentImpl(out);
           outs = newOuts;
       }

outs[depth].setWriter(writer);
       out = outs[depth];

// Update the value of the "out" attribute in the page scope
// attribute namespace of this PageContext
setAttribute(OUT, out);

       return outs[depth];
   }
 
源代码3 项目: sinavi-jfw   文件: JseErrorsTag.java
/**
 * {@inheritDoc}
 */
@Override
public void doTag() throws JspException, IOException {
    JspWriter out = getJspContext().getOut();
    Scope[] scopes = judge();
    if (scopes.length == 0) return;
    
    StringBuilder buffer = new StringBuilder();
    for (Scope s : scopes) {
        printMessages(buffer, s);
    }

    if (!onlyMsg && buffer.length() > 0) {
        out.print(HEADER + buffer.toString() + FOOTER);
    } else {
        out.print(buffer.toString());
    }
}
 
源代码4 项目: lams   文件: LAMSURLTag.java
@Override
   public int doStartTag() throws JspException {
String serverURL = Configuration.get(ConfigurationKeys.SERVER_URL);
serverURL = (serverURL != null ? serverURL.trim() : null);
if (serverURL != null && serverURL.length() > 0) {
    JspWriter writer = pageContext.getOut();
    try {
	writer.print(serverURL);
    } catch (IOException e) {
	log.error("ServerURLTag unable to write out server URL due to IOException. ", e);
	throw new JspException(e);
    }
} else {
    log.warn("ServerURLTag unable to write out server URL as it is missing from the configuration file.");
}

return SKIP_BODY;
   }
 
源代码5 项目: Tomcat8-Source-Read   文件: PageContextImpl.java
@Override
public JspWriter pushBody(Writer writer) {
    depth++;
    if (depth >= outs.length) {
        BodyContentImpl[] newOuts = new BodyContentImpl[depth + 1];
        for (int i = 0; i < outs.length; i++) {
            newOuts[i] = outs[i];
        }
        newOuts[depth] = new BodyContentImpl(out);
        outs = newOuts;
    }

    outs[depth].setWriter(writer);
    out = outs[depth];

    // Update the value of the "out" attribute in the page scope
    // attribute namespace of this PageContext
    setAttribute(OUT, out);

    return outs[depth];
}
 
源代码6 项目: spacewalk   文件: ColumnTag.java
/**
 * {@inheritDoc}
 */
public int doEndTag() throws JspException {
    JspWriter out = null;
    try {
        out = pageContext.getOut();

        if (!showHeader()) {
            if (showUrl()) {
                out.print(href.renderCloseTag());
            }
            out.print(td.renderCloseTag());
        }

        return Tag.EVAL_BODY_INCLUDE;
    }
    catch (IOException ioe) {
        throw new JspException("IO error writing to JSP file:", ioe);
    }
}
 
源代码7 项目: jeecg   文件: CkeditorTag.java
public int doEndTag() throws JspTagException {
	JspWriter out = null;
	try {
		out = this.pageContext.getOut();
		out.print(end().toString());
		out.flush();
	} catch (IOException e) {
		e.printStackTrace();
	}finally{
		try {
			out.clear();
			out.close();
		} catch (Exception e2) {
		}
	}
	return EVAL_PAGE;
}
 
源代码8 项目: uyuni   文件: ListTag.java
/** {@inheritDoc} */
public int doStartTag() throws JspException {
    JspWriter out = null;

    //if legend was set, process legends
    if (legend != null) {
        setLegends(legend);
    }

    try {
        out = pageContext.getOut();

        if (pageList == null || pageList.isEmpty()) {
            renderEmptyString(out);
            return SKIP_BODY;
        }

        return EVAL_BODY_INCLUDE;
    }
    catch (IOException ioe) {
        throw new JspException("IO error writing to JSP file:", ioe);
    }
}
 
源代码9 项目: netbeans   文件: SumBodyTagHandler.java
/**
 * Fill in this method to process the body content of the tag.
 * You only need to do this if the tag's BodyContent property
 * is set to "JSP" or "tagdependent."
 * If the tag's bodyContent is set to "empty," then this method
 * will not be called.
 */
private void writeTagBodyContent(JspWriter out, BodyContent bodyContent) throws IOException {
    //
    // TODO: insert code to write html before writing the body content.
    // e.g.:
    //
    out.println("<p>");
    out.println("Sum of " + x + " and " + y + " is " + (x+y));
    out.println("<br/>");
    
    //
    // write the body content (after processing by the JSP engine) on the output Writer
    //
    bodyContent.writeOut(out);
    
    out.println("<br/>");
    out.println("END of sum");
    out.println("</p>");
    
    
    // clear the body content for the next time through.
    bodyContent.clearBody();
}
 
源代码10 项目: tomcatsrc   文件: ValuesTag.java
@Override
public int doEndTag() throws JspException {
    JspWriter out = pageContext.getOut();

    try {
        if (!"-1".equals(objectValue)) {
            out.print(objectValue);
        } else if (!"-1".equals(stringValue)) {
            out.print(stringValue);
        } else if (longValue != -1) {
            out.print(longValue);
        } else if (doubleValue != -1) {
            out.print(doubleValue);
        } else {
            out.print("-1");
        }
    } catch (IOException ex) {
        throw new JspTagException("IOException: " + ex.toString(), ex);
    }
    return super.doEndTag();
}
 
源代码11 项目: anyline   文件: SubString.java
public int doEndTag() throws JspException { 
	//输出 
	JspWriter out = pageContext.getOut(); 
	String text = body; 
	if(null != text){
		int range[] = BasicUtil.range(begin, end, qty, text.length());
		text = text.substring(range[0],range[1]);
		try{ 
			out.print(text); 
		}catch(Exception e){ 
 
		}finally{ 
			release(); 
		} 
	} 
       return EVAL_PAGE;    
}
 
源代码12 项目: jeewx   文件: FormValidationTag.java
public int doStartTag() throws JspException {
	try {
		JspWriter out = this.pageContext.getOut();
		StringBuffer sb = new StringBuffer();
		if ("div".equals(layout)) {
			sb.append("<div id=\"content\">");
			sb.append("<div id=\"wrapper\">");
			sb.append("<div id=\"steps\">");
		}
		sb.append("<form id=\"" + formid + "\" action=\"" + action + "\" name=\"" + formid + "\" method=\"post\">");
		if ("btn_sub".equals(btnsub) && dialog)
			sb.append("<input type=\"hidden\" id=\"" + btnsub + "\" class=\"" + btnsub + "\"/>");
		out.print(sb.toString());
		out.flush();
	} catch (IOException e) {
		e.printStackTrace();
	}
	return EVAL_PAGE;
}
 
源代码13 项目: jeecg   文件: DictSelectTag.java
public int doEndTag() throws JspTagException {
	JspWriter out = null;
	try {
		out = this.pageContext.getOut();
		out.print(end().toString());
		out.flush();
	} catch (IOException e) {
		e.printStackTrace();
	}finally{
		try {
			out.clear();
			out.close();
			end().setLength(0);
		} catch (Exception e2) {
		}
	}
	return EVAL_PAGE;
}
 
源代码14 项目: lams   文件: WebAppURLTag.java
@Override
   public int doStartTag() throws JspException {
HttpServletRequest request = (HttpServletRequest) pageContext.getRequest();

String path = WebUtil.getBaseServerURL() + request.getContextPath();
if (!path.endsWith("/")) {
    path += "/";
}

try {
    JspWriter writer = pageContext.getOut();
    writer.print(path);
} catch (IOException e) {
    WebAppURLTag.log.error("ServerURLTag unable to write out server URL due to IOException. ", e);
    throw new JspException(e);
}
return Tag.SKIP_BODY;
   }
 
源代码15 项目: attic-rave   文件: ScriptTagTest.java
@Test
public void doStartTag_skip() throws IOException, JspException {

    List<String> strings = new ArrayList<String>();
    strings.add(SCRIPT);
    strings.add(SCRIPT_2);
    expect(service.getScriptBlocks(ScriptLocation.BEFORE_RAVE, context)).andReturn(null);
    replay(service);

    JspWriter writer = createNiceMock(JspWriter.class);
    replay(writer);

    expect(pageContext.getOut()).andReturn(writer).anyTimes();
    replay(pageContext);

    tag.setLocation(ScriptLocation.BEFORE_RAVE);
    int result = tag.doStartTag();
    assertThat(result, is(equalTo(TagSupport.SKIP_BODY)));
    verify(writer);
}
 
源代码16 项目: Bootstrap.jsp   文件: Modal.java
@Override
public void doTag() throws JspException, IOException {
	super.doTag();
	if (this.show != null) {
		if (!("true".equals(this.show) || "false".equals(this.show))) {
			final JspWriter writer = super.getJspContext().getOut();
            writer.println("<script type=\"text/javascript\">");
            writer.print("$(document).on('");
            writer.print(this.show);
            writer.println("', function() { ");
            writer.print("$('.modal[data-show=\"");
            writer.print(this.show);
            writer.println("\"]:hidden').modal();");
            writer.println("});");
            writer.println("</script>");
		}
	}
}
 
源代码17 项目: RDFS   文件: JobTrackerJspHelper.java
/**
 * Generates an XML-formatted block that summarizes the state of the JobTracker.
 */
public void generateSummaryTable(JspWriter out,
                                 JobTracker tracker) throws IOException {
  ClusterStatus status = tracker.getClusterStatus();
  int maxMapTasks = status.getMaxMapTasks();
  int maxReduceTasks = status.getMaxReduceTasks();
  int numTaskTrackers = status.getTaskTrackers();
  String tasksPerNodeStr;
  if (numTaskTrackers > 0) {
    double tasksPerNodePct = (double) (maxMapTasks + maxReduceTasks) / (double) numTaskTrackers;
    tasksPerNodeStr = percentFormat.format(tasksPerNodePct);
  } else {
    tasksPerNodeStr = "-";
  }
  out.print("<maps>" + status.getMapTasks() + "</maps>\n" +
          "<reduces>" + status.getReduceTasks() + "</reduces>\n" +
          "<total_submissions>" + tracker.getTotalSubmissions() + "</total_submissions>\n" +
          "<nodes>" + status.getTaskTrackers() + "</nodes>\n" +
          "<map_task_capacity>" + status.getMaxMapTasks() + "</map_task_capacity>\n" +
          "<reduce_task_capacity>" + status.getMaxReduceTasks() + "</reduce_task_capacity>\n" +
          "<avg_tasks_per_node>" + tasksPerNodeStr + "</avg_tasks_per_node>\n");
}
 
源代码18 项目: uyuni   文件: ToolTipTag.java
/**
 * {@inheritDoc}
 */
@Override
public int doStartTag() throws JspException {
    LocalizationService ls = LocalizationService.getInstance();
    HtmlTag strong = new HtmlTag("strong");
    strong.addBody(ls.getMessage(geTypeKey()) + ": ");

    JspWriter writer = pageContext.getOut();
    try {
        writer.write("<p class=\"small-text\">");
        writer.write(strong.render());
        if (!StringUtils.isBlank(key)) {
            writer.write(ls.getMessage(key));
        }
        return EVAL_BODY_INCLUDE;
    }
    catch (IOException e) {
        throw new JspException(e);
    }

}
 
源代码19 项目: uyuni   文件: ConfigChannelTag.java
/**
 * {@inheritDoc}
 */
public int doEndTag() throws JspException {
    StringBuilder result = new StringBuilder();
    if (nolink || id == null) {
        result.append(writeIcon());
        result.append(name);
    }
    else {
        result.append("<a href=\"" +
                    ConfigChannelTag.makeConfigChannelUrl(id) + "\">");
        result.append(writeIcon());
        result.append(StringEscapeUtils.escapeXml(name) + "</a>");
    }
    JspWriter writer = pageContext.getOut();
    try {
        writer.write(result.toString());
    }
    catch (IOException e) {
        throw new JspException(e);
    }
    return BodyTagSupport.SKIP_BODY;
}
 
源代码20 项目: jeecg   文件: UploadTag.java
public int doEndTag() throws JspTagException {
	JspWriter out = null;
	try {
		out = this.pageContext.getOut();
		out.print(end().toString());
		out.flush();
	} catch (IOException e) {
		e.printStackTrace();
	}finally{
		try {
			out.clear();
			out.close();
		} catch (Exception e2) {
		}
	}
	return EVAL_PAGE;
}
 
源代码21 项目: jstorm   文件: SubMetricTag.java
@Override
public void doTag() throws JspException {
    JspWriter out = getJspContext().getOut();
    try {
        StringBuilder sb = new StringBuilder();
        if (metric.size() > 0) {
            if (isHidden) {
                sb.append(String.format("<div class='%s hidden'>", clazz));
            } else {
                sb.append(String.format("<div class='%s'>", clazz));
            }
            for (String parent : parentComp) {
                String key = metricName + "@" + parent;
                String v = metric.get(key);
                if (v != null) {
                    sb.append(v);
                }
                sb.append("<br/>");
            }
            sb.append("</div>");
            out.write(sb.toString());
        }
    } catch (IOException e) {
        throw new JspException("Error: " + e.getMessage());
    }
}
 
源代码22 项目: netbeans   文件: SumBodyTagHandler.java
/**
 * This method is called after the JSP engine processes the body content of the tag.
 * @return EVAL_BODY_AGAIN if the JSP engine should evaluate the tag body again, otherwise return SKIP_BODY.
 * This method is automatically generated. Do not modify this method.
 * Instead, modify the methods that this method calls.
 */
public int doAfterBody() throws JspException {
    try {
        //
        // This code is generated for tags whose bodyContent is "JSP"
        //
        BodyContent bodyContent = getBodyContent();
        JspWriter out = bodyContent.getEnclosingWriter();
        
        writeTagBodyContent(out, bodyContent);
    } catch (Exception ex) {
        handleBodyContentException(ex);
    }
    
    if (theBodyShouldBeEvaluatedAgain()) {
        return EVAL_BODY_AGAIN;
    } else {
        return SKIP_BODY;
    }
}
 
源代码23 项目: portals-pluto   文件: NamespaceTag.java
public int doStartTag() throws JspException {
	
	PortletResponse portletResponse = (PortletResponse) pageContext.getRequest()
        .getAttribute(Constants.PORTLET_RESPONSE);
	
    String namespace = portletResponse.getNamespace();
    
    JspWriter writer = pageContext.getOut();
    
    try {
        writer.print(namespace);
    } catch (IOException ioe) {
        throw new JspException(
            "Unable to write namespace", ioe
        );
    }
    
    return SKIP_BODY;
}
 
源代码24 项目: velocity-tools   文件: VelocityBodyContent.java
/**
 * Constructor.
 *
 * @param jspWriter The JSP writer to be used by default.
 * @param block The block to wrap.
 * @param context The directive context.
 */
public VelocityBodyContent(JspWriter jspWriter, ASTBlock block,
        InternalContextAdapter context)
{
    super(jspWriter);
    this.block = block;
    this.context = context;
}
 
源代码25 项目: tomcatsrc   文件: Out.java
public static boolean output(JspWriter out, Object input, String value,
        String defaultValue, boolean escapeXml) throws IOException {
    if (input instanceof Reader) {
        char[] buffer = new char[8096];
        int read = 0;
        while (read != -1) {
            read = ((Reader) input).read(buffer);
            if (read != -1) {
                if (escapeXml) {
                    String escaped = Util.escapeXml(buffer, read);
                    if (escaped == null) {
                        out.write(buffer, 0, read);
                    } else {
                        out.print(escaped);
                    }
                } else {
                    out.write(buffer, 0, read);
                }
            }
        }
        return true;
    } else {
        String v = value != null ? value : defaultValue;
        if (v != null) {
            if(escapeXml){
                v = Util.escapeXml(v);
            }
            out.write(v);
            return true;
        } else {
            return false;
        }
    }
}
 
源代码26 项目: Openfire   文件: FlashMessageTag.java
@Override
public void doTag() throws IOException {
    final PageContext pageContext = (PageContext) getJspContext();
    final JspWriter jspWriter = pageContext.getOut();
    final HttpSession session = pageContext.getSession();

    for (final String flash : new String[]{SUCCESS_MESSAGE_KEY, WARNING_MESSAGE_KEY, ERROR_MESSAGE_KEY}) {
        final Object flashValue = session.getAttribute(flash);
        if (flashValue != null) {
            jspWriter.append(String.format("<div class='%s'>%s</div>", flash, flashValue));
            session.setAttribute(flash, null);
        }
    }

}
 
源代码27 项目: kfs   文件: AccountingLineTableHeaderRenderer.java
/**
 * Renders the header for the accounting line table to the screen
 * @see org.kuali.kfs.sys.document.web.renderers.Renderer#render(javax.servlet.jsp.PageContext, javax.servlet.jsp.tagext.Tag)
 */
public void render(PageContext pageContext, Tag parentTag) throws JspException {
    JspWriter out = pageContext.getOut();
    
    try {
        out.write(buildDivStart());
        out.write(buildTableStart());
        out.write(buildSubheadingWithDetailToggleRowBeginning());
        renderHideDetails(pageContext, parentTag);
        out.write(buildSubheadingWithDetailToggleRowEnding());
    }
    catch (IOException ioe) {
        throw new JspException("Difficulty rendering AccountingLineTableHeader", ioe);
    }
}
 
源代码28 项目: Tomcat8-Source-Read   文件: JspRuntimeLibrary.java
public static JspWriter startBufferedBody(PageContext pageContext, BodyTag tag)
        throws JspException {
    BodyContent out = pageContext.pushBody();
    tag.setBodyContent(out);
    tag.doInitBody();
    return out;
}
 
源代码29 项目: lognavigator   文件: RawContentTag.java
@Override
public int doEndTag() throws JspException {
	
	// Get input and ouput variables
	Reader rawContent = (Reader) pageContext.getAttribute(Constants.RAW_CONTENT_KEY, PageContext.REQUEST_SCOPE);
	JspWriter out = pageContext.getOut();
	
	try {
		// Copy input (rawContent) to output (out)
		char[] buffer = new char[StreamUtils.BUFFER_SIZE];
		int bytesRead = -1;
		while ((bytesRead = rawContent.read(buffer)) != -1) {
			String stringToWrite = new String(buffer, 0, bytesRead);
			stringToWrite = HtmlUtils.htmlEscape(stringToWrite);
			out.write(stringToWrite);
		}
		out.flush();

		return EVAL_PAGE;
	}
	catch (IOException e) {
		throw new JspException(e);
	}
	finally {
		IOUtils.closeQuietly(rawContent);
	}
}
 
源代码30 项目: jeewx   文件: ChooseTag.java
public int doEndTag() throws JspTagException {
	try {
		JspWriter out = this.pageContext.getOut();
		out.print(end().toString());
		out.flush();
	} catch (IOException e) {
		e.printStackTrace();
	}
	return EVAL_PAGE;
}
 
 类所在包
 同包方法