當前位置: 首頁>>代碼示例>>Java>>正文


Java BodyContent類代碼示例

本文整理匯總了Java中javax.servlet.jsp.tagext.BodyContent的典型用法代碼示例。如果您正苦於以下問題:Java BodyContent類的具體用法?Java BodyContent怎麽用?Java BodyContent使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


BodyContent類屬於javax.servlet.jsp.tagext包,在下文中一共展示了BodyContent類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: include

import javax.servlet.jsp.tagext.BodyContent; //導入依賴的package包/類
/**
 * Perform a RequestDispatcher.include() operation, with optional flushing
 * of the response beforehand.
 *
 * @param request The servlet request we are processing
 * @param response The servlet response we are processing
 * @param relativePath The relative path of the resource to be included
 * @param out The Writer to whom we are currently writing
 * @param flush Should we flush before the include is processed?
 *
 * @exception IOException if thrown by the included servlet
 * @exception ServletException if thrown by the included servlet
 */
public static void include(ServletRequest request,
                           ServletResponse response,
                           String relativePath,
                           JspWriter out,
                           boolean flush)
    throws IOException, ServletException {

    if (flush && !(out instanceof BodyContent))
        out.flush();

    // FIXME - It is tempting to use request.getRequestDispatcher() to
    // resolve a relative path directly, but Catalina currently does not
    // take into account whether the caller is inside a RequestDispatcher
    // include or not.  Whether Catalina *should* take that into account
    // is a spec issue currently under review.  In the mean time,
    // replicate Jasper's previous behavior

    String resourcePath = getContextRelativePath(request, relativePath);
    RequestDispatcher rd = request.getRequestDispatcher(resourcePath);

    rd.include(request,
               new ServletResponseWrapperInclude(response, out));

}
 
開發者ID:liaokailin,項目名稱:tomcat7,代碼行數:38,代碼來源:JspRuntimeLibrary.java

示例2: writePrevious

import javax.servlet.jsp.tagext.BodyContent; //導入依賴的package包/類
/**
 * Write the specified text as the response to the writer associated with
 * the body content for the tag within which we are currently nested.
 *
 * @param pageContext The PageContext object for this page
 * @param text The text to be written
 *
 * @exception JspException if an input/output error occurs (already saved)
 */
public void writePrevious(PageContext pageContext, String text)
        throws JspException {

    JspWriter writer = pageContext.getOut();
    if (writer instanceof BodyContent) {
        writer = ((BodyContent) writer).getEnclosingWriter();
    }

    try {
        writer.print(text);

    } catch (IOException e) {
        TagUtils.getInstance().saveException(pageContext, e);
        throw new JspException
                (messages.getMessage("write.io", e.toString()));
    }

}
 
開發者ID:lamsfoundation,項目名稱:lams,代碼行數:28,代碼來源:TagUtils.java

示例3: doAfterBody

import javax.servlet.jsp.tagext.BodyContent; //導入依賴的package包/類
/** .//GEN-BEGIN:doAfterbody
 *
 *
 * 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.
 * @throws JspException
 * @throws JspException  */
public int doAfterBody() throws JspException, JspException {
    try {
        //
        // This code is generated for tags whose bodyContent is "JSP"
        //
        JspWriter out = getPreviousOut();
        BodyContent bodyContent = getBodyContent();

        writeTagBodyContent(out, bodyContent);
    } catch (Exception ex) {
        throw new JspException("error in FunctionGuardTag: " + ex);
    }

    if (theBodyShouldBeEvaluatedAgain()) {
        return EVAL_BODY_AGAIN;
    } else {
        return SKIP_BODY;
    }
}
 
開發者ID:jaffa-projects,項目名稱:jaffa-framework,代碼行數:29,代碼來源:FunctionGuardTag.java

示例4: doAfterBody

import javax.servlet.jsp.tagext.BodyContent; //導入依賴的package包/類
/** .//GEN-BEGIN:doAfterbody
 *
 *
 * 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.
 * @throws JspException  */
public int doAfterBody() throws JspException {
    try {
        //
        // This code is generated for tags whose bodyContent is "JSP"
        //
        JspWriter out = getPreviousOut();
        BodyContent bodyContent = getBodyContent();

        writeTagBodyContent(out, bodyContent);
    } catch (Exception ex) {
        throw new JspException("error in ComponentGuardTag: " + ex);
    }

    if (theBodyShouldBeEvaluatedAgain()) {
        return EVAL_BODY_AGAIN;
    } else {
        return SKIP_BODY;
    }
}
 
開發者ID:jaffa-projects,項目名稱:jaffa-framework,代碼行數:28,代碼來源:ComponentGuardTag.java

示例5: writePrevious

import javax.servlet.jsp.tagext.BodyContent; //導入依賴的package包/類
/**
 * Write the specified text as the response to the writer associated with
 * the body content for the tag within which we are currently nested.
 *
 * @param pageContext The PageContext object for this page
 * @param text        The text to be written
 * @throws JspException if an input/output error occurs (already saved)
 */
public void writePrevious(PageContext pageContext, String text)
    throws JspException {
    JspWriter writer = pageContext.getOut();

    if (writer instanceof BodyContent) {
        writer = ((BodyContent) writer).getEnclosingWriter();
    }

    try {
        writer.print(text);
    } catch (IOException e) {
        saveException(pageContext, e);
        throw new JspException(messages.getMessage("write.io", e.toString()));
    }
}
 
開發者ID:SonarSource,項目名稱:sonar-scanner-maven,代碼行數:24,代碼來源:TagUtils.java

示例6: doEndTag

import javax.servlet.jsp.tagext.BodyContent; //導入依賴的package包/類
public int doEndTag() {
	BodyContent body = this.getBodyContent();
	String html = body.getString() + "</html>";
	try {
		html = resource.replace(html);
	} catch (FisException e1) {
		// TODO Auto-generated catch block
		e1.printStackTrace();
	}
	JspWriter out = pageContext.getOut();
	try {
		out.write(html);
	} catch (IOException e) {
		// TODO Auto-generated catch block
		e.printStackTrace();
	}
	return EVAL_PAGE;
}
 
開發者ID:bignippleboy,項目名稱:ipaas,代碼行數:19,代碼來源:HtmlTag.java

示例7: doEndTag

import javax.servlet.jsp.tagext.BodyContent; //導入依賴的package包/類
@Override
public int doEndTag() throws JspException {
	// TODO Auto-generated method stub
	//�ڽ�����ǩʱ��ñ�ǩ�����ݣ�Ȼ�������޸�
	BodyContent bc=this.getBodyContent();
	String content=bc.getString();
	content=content.toUpperCase();
	try {
		this.pageContext.getOut().write(content);
	} catch (IOException e) {
		// TODO Auto-generated catch block
		throw new RuntimeException(e);
	}
	return Tag.EVAL_PAGE;//����ֻ�ǶԱ�ǩ�����������޸ģ������jsp���ݻ�Ҫִ����ʾ������˴�����EVAL_PAGE
	//return super.doEndTag();
}
 
開發者ID:mushroomgithub,項目名稱:ServletStudyDemo,代碼行數:17,代碼來源:TagDemo4.java

示例8: loadComponent

import javax.servlet.jsp.tagext.BodyContent; //導入依賴的package包/類
public static ComponentImpl loadComponent(PageContext pc,Page page, PageSource ps,String callPath, boolean isRealPath, boolean silent) throws PageException  {
	/*if(page==null && ps instanceof PageSourceImpl) {
		page=((PageSourceImpl)ps).getPage();
	}*/
	if(silent) {
		// TODO is there a more direct way
		BodyContent bc =  pc.pushBody();
		try {
			return loadComponent(pc,page,ps,callPath,isRealPath);
		}
		finally {
			BodyContentUtil.clearAndPop(pc, bc);
		}
	}
	return loadComponent(pc,page,ps,callPath,isRealPath);
}
 
開發者ID:lucee,項目名稱:Lucee4,代碼行數:17,代碼來源:ComponentLoader.java

示例9: doAfterBody

import javax.servlet.jsp.tagext.BodyContent; //導入依賴的package包/類
/**
 * Method called at end of format tag body.
 *
 * @return SKIP_BODY
 */
public final int doAfterBody() throws JspException
{
    // Use the body of the tag as input for the date
    BodyContent body = getBodyContent();
    String s = body.getString().trim();  
    // Clear the body since we will output only the formatted date
    body.clearBody();
    if( output_date == null ) {
        long time;
        try {
            time = Long.valueOf(s).longValue();
            output_date = new Date(time);
        } catch(NumberFormatException nfe) {
        }
    }

    return SKIP_BODY;
}
 
開發者ID:lucee,項目名稱:Lucee4,代碼行數:24,代碼來源:FormatTag.java

示例10: doAfterBody

import javax.servlet.jsp.tagext.BodyContent; //導入依賴的package包/類
/** 
 * Actions after some body has been evaluated.
 */
@Override
public int doAfterBody() throws JspTagException {
  // put out the evaluated body
  BodyContent body = getBodyContent();
  JspWriter out = body.getEnclosingWriter();
  try {
    out.print( body.getString() );
  } catch(IOException ioe) {
    throw new NavigatorRuntimeException("Error in IfTag.", ioe);
  }

  parentChooser.setFoundMatchingWhen();
  
  return SKIP_BODY;
}
 
開發者ID:ontopia,項目名稱:ontopia,代碼行數:19,代碼來源:OtherwiseTag.java

示例11: doAfterBody

import javax.servlet.jsp.tagext.BodyContent; //導入依賴的package包/類
/**
 * Actions after some body has been evaluated.
 */
@Override
public int doAfterBody() throws JspTagException {

  // retrieve parent tag which accepts the result of this operation
  ValueAcceptingTagIF acceptingTag = (ValueAcceptingTagIF)
    findAncestorWithClass(this, ValueAcceptingTagIF.class);

  // get body content which should contain the string we want to set.
  BodyContent body = getBodyContent();
  String content = body.getString();

  // construct new collection which consists of one String entry
  // kick it over to the nearest accepting tag
  acceptingTag.accept( Collections.singleton(content) );

  // reset body contents
  body.clearBody();
  
  return SKIP_BODY;
}
 
開發者ID:ontopia,項目名稱:ontopia,代碼行數:24,代碼來源:StringTag.java

示例12: doAfterBody

import javax.servlet.jsp.tagext.BodyContent; //導入依賴的package包/類
/**
 * Actions after some body has been evaluated.
 */
@Override
public int doAfterBody() throws JspTagException {
  ElementTag elementTag = (ElementTag)
    findAncestorWithClass(this, ElementTag.class);

  if (elementTag != null) {
    // get body content
    BodyContent body = getBodyContent();
    if (body != null) {
      String content = body.getString();
      // add this attribute to parent element tag 
      elementTag.addAttribute(attrName, content);
      body.clearBody();
    } else {
      log.warn("AttributeTag: body content is null!");
    }
  } else {
    log.warn("AttributeTag: no parent element tag found!");
  }
  
  // only evaluate body once
  return SKIP_BODY;
}
 
開發者ID:ontopia,項目名稱:ontopia,代碼行數:27,代碼來源:AttributeTag.java

示例13: doAfterBody

import javax.servlet.jsp.tagext.BodyContent; //導入依賴的package包/類
/**
 * Actions after some body has been evaluated.
 */
@Override
public int doAfterBody() throws JspTagException {
  // put out the evaluated body
  BodyContent body = getBodyContent();
  JspWriter out = null;
  try {
    out = body.getEnclosingWriter();
    out.print(body.getString());
    body.clearBody();
  } catch(IOException ioe) {
    throw new NavigatorRuntimeException("Error in AssociationTypeLoopTag.", ioe);
  }

  // test if we have to repeat the body 
  if (index < assocStore.length) {
    // set to next value in list
    setVariableValues(assocStore[index]);
    index++;
    return EVAL_BODY_AGAIN;
  } else {
    return SKIP_BODY;
  }
  
}
 
開發者ID:ontopia,項目名稱:ontopia,代碼行數:28,代碼來源:AssociationTypeLoopTag.java

示例14: getHandlePageException

import javax.servlet.jsp.tagext.BodyContent; //導入依賴的package包/類
public static String getHandlePageException(PageContextImpl pc, PageException pe) throws PageException {
	BodyContent bc = null;
	String str = null;
	try {
		bc = pc.pushBody();
		pc.handlePageException(pe, false);
	}
	catch (Throwable t) {
		ExceptionUtil.rethrowIfNecessary(t);
		throw Caster.toPageException(t);
	} finally {
		if(bc != null)
			str = bc.getString();
		pc.popBody();
	}
	return str;
}
 
開發者ID:lucee,項目名稱:Lucee,代碼行數:18,代碼來源:PageContextUtil.java

示例15: tag

import javax.servlet.jsp.tagext.BodyContent; //導入依賴的package包/類
public static Result tag(PageContext pc, String cfml, int dialect, boolean catchOutput, boolean ignoreScopes) throws PageException {
	// execute
	Result res=new Result();
	BodyContent bc=null;
	//Variables before = pc.variablesScope();
	try{
		if(catchOutput)bc = pc.pushBody();
		//if(variables!=null)pc.setVariablesScope(variables);
		
		res.value=loadPage(pc.getConfig(), null, cfml,dialect,ignoreScopes).call(pc);
	}
	catch(Throwable t){
		ExceptionUtil.rethrowIfNecessary(t);
		throw Caster.toPageException(t);
	}
	finally{
		//if(variables!=null)pc.setVariablesScope(before);
		if(catchOutput) {
			if(bc!=null)res.output=bc.getString();
			pc.popBody();
		}
		//pc.flush();
	}
	return res;
}
 
開發者ID:lucee,項目名稱:Lucee,代碼行數:26,代碼來源:Renderer.java


注:本文中的javax.servlet.jsp.tagext.BodyContent類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。