当前位置: 首页>>代码示例>>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;未经允许,请勿转载。