javax.servlet.jsp.JspWriter#print ( )源码实例Demo

下面列出了javax.servlet.jsp.JspWriter#print ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: jeecg   文件: UserSelectTag.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;
}
 
源代码2 项目: uyuni   文件: IconTag.java
/** {@inheritDoc}
 * @throws JspException JSP exception
 */
public int doStartTag() throws JspException {
    if (!icons.containsKey(type)) {
        throw new IllegalArgumentException("Unknown icon type: \"" + type + "\".");
    }

    JspWriter out = null;
    try {
        out = pageContext.getOut();
        String result = renderStartTag();
        out.print(result);
    }
    catch (IOException ioe) {
        throw new JspException("IO error writing to JSP file:", ioe);
    }
    return SKIP_BODY;
}
 
源代码3 项目: 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);
    }
}
 
源代码4 项目: 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();
}
 
源代码5 项目: anyline   文件: Replace.java
public int doEndTag() throws JspException {
	 String src = BasicUtil.nvl(value,body,"").toString().trim();
	 if(BasicUtil.isEmpty(src)){
		 return EVAL_BODY_INCLUDE;
	 }
	 if(null == from || from.length()==0){
		 return EVAL_BODY_INCLUDE;
	 }
	if(BasicUtil.isEmpty(to)){
		to = "";
	}
	JspWriter writer = null;
	try {
		writer = pageContext.getOut();
		writer.print(src.replace(from, to));
	} catch (IOException e) {
		e.printStackTrace();
	}finally{
		release();
	}
	return EVAL_PAGE;// 标签执行完毕之后继续执行下面的内容
}
 
源代码6 项目: jeecg   文件: ComboTreeTag.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;
}
 
源代码7 项目: sinavi-jfw   文件: JseMessagesTag.java
/**
 * {@inheritDoc}
 */
@Override
public void doTag() throws JspException, IOException {
    JspWriter out = getJspContext().getOut();
    StringBuilder buffer = new StringBuilder();
    for (String key : MessageContext.MESSAGES_KEY) {
        Messages messages = extractMessagesAsList(key);
        if (messages != null && !messages.isEmpty()) {
            switch (messages.getMessageType()) {
            case ERROR:
                printMessages(buffer, messages.getMessageItemList(), ERROR_PREFIX, ERROR_SUFFIX);
                break;
            case INFORMATION:
                printMessages(buffer, messages.getMessageItemList(), INFO_PREFIX, INFO_SUFFIX);
                break;
            case VALIDATION:
            default:
                printMessages(buffer, messages.getMessageItemList(), VALIDATION_PREFIX, VALIDATION_SUFFIX);
                break;
            }
        }
    }
    if (!onlyMsg && buffer.length() > 0) {
        out.print(HEADER + buffer.toString() + FOOTER);
    } else {
        out.print(buffer.toString());
    }
}
 
源代码8 项目: 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;
}
 
源代码9 项目: hadoop-gpu   文件: JspHelper.java
public static void createTitle(JspWriter out, 
    HttpServletRequest req, String  file) throws IOException{
  if(file == null) file = "";
  int start = Math.max(0,file.length() - 100);
  if(start != 0)
    file = "..." + file.substring(start, file.length());
  out.print("<title>HDFS:" + file + "</title>");
}
 
源代码10 项目: Tomcat7.0.67   文件: 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;
        }
    }
}
 
源代码11 项目: anyline   文件: DESHttpRequestParamValue.java
public int doEndTag() throws JspException { 
	try{ 
		JspWriter out = pageContext.getOut(); 
		out.print(DESUtil.encryptParamValue(BasicUtil.nvl(value,body,"").toString())); 
	}catch(Exception e){ 
		e.printStackTrace(); 
	}finally{ 
		release(); 
	} 
	return EVAL_PAGE; 
}
 
源代码12 项目: webcurator   文件: ListTypeRenderer.java
public void render(ProfileElement element, PageContext context, RendererFilter filter) throws IOException {
	JspWriter out = context.getOut();
	
	ListType list = (ListType) element.getValue();

	out.println("<input type=\"hidden\" name=\"" + element.getAbsoluteName() + "\" id=\"" + element.getAbsoluteName() + "\">");
	out.println("<select multiple id=\"" + element.getAbsoluteName() + ".list\" size=\"5\" style=\"width: 500px\">");
	for(int i=0 ; i<list.size() ; i++){
           out.println("<option value='" + list.get(i) +"'>"+list.get(i)+"</option>");
       }
	out.println("</select>");

	out.println("<a  onclick=\"removeFromList('"+element.getAbsoluteName()+"');\"><image src=\"images/action-icon-delete.gif\" alt=\"Remove\"></a><br/>");
	
	out.print("<input id=\"");
	out.print(element.getAbsoluteName() + ".new");
	out.print("\" type=\"text\">");
	out.println("<a onclick=\"addToList('"+element.getAbsoluteName()+"');\"><image src=\"images/subtabs-add-btn.gif\" style=\"vertical-align: bottom\" alt=\"Add\"></a>");

	
	// Set the text field.
	out.println("<script>");
	out.println("var val = document.getElementById('" + element.getAbsoluteName() + "').value;");
	for(int i=0 ; i<list.size() ; i++){
		if( i == 0) { 
			out.println("val = val + '" + TextUtils.escapeForHTMLJavascript(list.get(i).toString()) + "';");
		}
		else {
			out.println("val = val + '\\n' + '" + TextUtils.escapeForHTMLJavascript(list.get(i).toString()) +"';");
		}
       }
	out.println("document.getElementById('" + element.getAbsoluteName() + "').value = val;");		
	out.println("</script>");
	
	out.println("<br/>");
	
}
 
源代码13 项目: jeewx   文件: DataGridTag.java
public int doEndTag() throws JspException {
	try {
		JspWriter out = this.pageContext.getOut();
		if (style.equals("easyui")) {
			out.print(end().toString());
		} else {
			out.print(datatables().toString());
			out.flush();
		}
	} catch (IOException e) {
		e.printStackTrace();
	}
	return EVAL_PAGE;
}
 
源代码14 项目: jeewx   文件: TabsTag.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;
}
 
源代码15 项目: jeewx   文件: DictSelectTag.java
public int doEndTag() throws JspTagException {
	try {
		JspWriter out = this.pageContext.getOut();
		out.print(end().toString());
	} catch (IOException e) {
		e.printStackTrace();
	}
	return EVAL_PAGE;
}
 
源代码16 项目: MavenIn28Minutes   文件: StatusLabelTag.java
@Override
public void doTag() throws JspException, IOException {

	JspWriter out = getJspContext().getOut();
	String statusLabel = TodoListUtils.getStatusLabel(status);
	out.print(statusLabel);

}
 
源代码17 项目: Movie_Recommend   文件: NavigationTag.java
@Override
public int doStartTag() throws JspException {
    JspWriter writer = pageContext.getOut();
    HttpServletRequest request = (HttpServletRequest) pageContext.getRequest();
    Page page = (Page)request.getAttribute(bean);
    if (page == null)
        return SKIP_BODY;
    url = resolveUrl(url, pageContext);
    try {
        //计算总页数
        int pageCount = page.getTotal() / page.getSize();
        if (page.getTotal() % page.getSize() > 0) {
            pageCount++;
        }
        writer.print("<nav><ul class=\"pagination\">");
        //显示“上一页”按钮
        if (page.getPage() > 1) {
            String preUrl = append(url, "page", page.getPage() - 1);
            preUrl = append(preUrl, "rows", page.getSize());
            writer.print("<li><a href=\"" + preUrl + "\">上一页</a></li>");
        } else {
            writer.print("<li class=\"disabled\"><a href=\"#\">上一页</a></li>");
        }
        //显示当前页码的前2页码和后两页码
        //若1 则 1 2 3 4 5, 若2 则 1 2 3 4 5, 若3 则1 2 3 4 5,
        //若4 则 2 3 4 5 6 ,若10  则 8 9 10 11 12
        int indexPage = (page.getPage() - 2 > 0)? page.getPage() - 2 : 1;
        for(int i=1; i <= number && indexPage <= pageCount; indexPage++, i++) {
            if(indexPage == page.getPage()) {
                writer.print( "<li class=\"active\"><a href=\"#\">"+indexPage+"<span class=\"sr-only\">(current)</span></a></li>");
                continue;
            }
            String pageUrl  = append(url, "page", indexPage);
            pageUrl = append(pageUrl, "rows", page.getSize());
            writer.print("<li><a href=\"" + pageUrl + "\">"+ indexPage +"</a></li>");
        }
        //显示“下一页”按钮
        if (page.getPage() < pageCount) {
            String nextUrl  = append(url, "page", page.getPage() + 1);
            nextUrl = append(nextUrl, "rows", page.getSize());
            writer.print("<li><a href=\"" + nextUrl + "\">下一页</a></li>");
        } else {
            writer.print("<li class=\"disabled\"><a href=\"#\">下一页</a></li>");
        }
        writer.print("</nav>");
    } catch (IOException e) {
        e.printStackTrace();
    }
    return SKIP_BODY;
}
 
源代码18 项目: uyuni   文件: SetTag.java
/**
 * {@inheritDoc}
 */
protected void renderData(JspWriter out, ListDisplayTag parent)
    throws IOException {
    super.renderData(out, parent);
    //Render contents of column here
    HtmlTag cbox = new HtmlTag("input");
    if (type == null || type.equals("checkbox")) {
        cbox.setAttribute("type", "checkbox");
        cbox.setAttribute("onclick", "checkbox_clicked(this, '" +
                          getSet().getLabel() + "')");
    }
    else {
        cbox.setAttribute("type", "radio");
    }
    cbox.setAttribute("name", "items_selected");
    cbox.setAttribute("value", getValue());

    //Should checkbox be checked?
    if (checkboxChecked()) {
        cbox.setAttribute("checked", "true");
        parent.incrementChecked();
    }

    //Should checkbox be disabled?
    if (disabled) {
        cbox.setAttribute("disabled", "disabled");
    }

    if (this.getTitle() != null) {
        cbox.setAttribute("title", LocalizationService.getInstance()
                          .getMessage(this.getTitle()));
    }

    if (this.getAlt() != null) {
        cbox.setAttribute("alt", LocalizationService.getInstance()
                          .getMessage(this.getAlt()));
    }

    HtmlTag hideme = new HtmlTag("input");
    hideme.setAttribute("type", "hidden");
    hideme.setAttribute("name", "items_on_page");
    hideme.setAttribute("value", getValue());

    out.print(cbox.render() + "\n" + hideme.render());
}
 
源代码19 项目: anyline   文件: NumberFormat.java
public int doEndTag() throws JspException { 
	try{ 
		String result = null;
		if(null == value){ 
			value = body;
		}
		if(BasicUtil.isEmpty(value)){
			value = def;
		}
		if(BasicUtil.isNotEmpty(value)){
			BigDecimal num = new BigDecimal(value.toString());
			if(BasicUtil.isNotEmpty(min)){
				BigDecimal minNum = new BigDecimal(min.toString());
				if(minNum.compareTo(num) > 0){
					num = minNum;
					log.warn("[number format][value:{}][小于最小值:{}]", num,min);
				}
			}
			if(BasicUtil.isNotEmpty(max)){
				BigDecimal maxNum = new BigDecimal(max.toString());
				if(maxNum.compareTo(num) < 0){
					num = maxNum;
					log.warn("[number format][value:{}][超过最大值:{}]",num, max);
				}
			} 
			result = NumberUtil.format(num,format);
		}else{
			if(null == result && null != nvl){
				result = nvl.toString();
			}
			if(BasicUtil.isEmpty(result) && null != evl){
				result = evl.toString();
			}
		}
		if(null != result) {
			JspWriter out = pageContext.getOut();
			out.print(result);
		}
	}catch(Exception e){ 
		e.printStackTrace(); 
	}finally{ 
		release(); 
	} 
       return EVAL_PAGE;    
}
 
源代码20 项目: ontopia   文件: ForEachTag.java
/** 
 * Actions after some body has been evaluated.
 */
@Override
public int doAfterBody() throws JspTagException {
  JspWriter jspWriter;

  try {
    // Get the writer to output the query result.
    jspWriter = getBodyContent().getEnclosingWriter();
    jspWriter.print( getBodyContent().getString() );
  } catch (IOException e) {
    throw new NavigatorRuntimeException("Error in ForEachTag.", e);
  }
    
  // If current row is relevant to the grouping ancestor.
  if (groupingAncestor != null && groupingAncestor.needsCurrentRow())
    return SKIP_BODY;  
  
  // If the end of the query result has been reached.
  if (!queryWrapper.hasNext())
    return SKIP_BODY;
  
  // Move to next row in query result.  
  queryWrapper.next();
  queryWrapper.bindVariables(groupColumns);

  sequenceNumber++;
    
  // insert separating string (if any)
  if (separator != null) {
    try {  
      jspWriter.print( separator );
    } catch(IOException ioe) {
      throw new NavigatorRuntimeException("Error in ForEachTag.", ioe);
    }
  }

  boolean isLast = !queryWrapper.hasNext() ||
    (groupingAncestor != null && (groupingAncestor.needsCurrentRow() || queryWrapper.isOnlyChild(groupingAncestor.groupColumns, groupColumns)));
  queryWrapper.getContextManager().setValue(SEQUENCE_FIRST, FALSE);
  queryWrapper.getContextManager().setValue(SEQUENCE_NUMBER, Integer.toString(sequenceNumber));
  queryWrapper.getContextManager().setValue(SEQUENCE_LAST, isLast ? TRUE : FALSE);
  
  // Prepare for next iteration.
  getBodyContent().clearBody();
  return EVAL_BODY_AGAIN;
}