Java 类javax.servlet.jsp.tagext.BodyContent 实例源码

项目:tomcat7    文件:JspRuntimeLibrary.java   
/**
 * 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));

}
项目:lams    文件:JspRuntimeLibrary.java   
/**
 * 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));

}
项目:lams    文件:TagUtils.java   
/**
 * 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()));
    }

}
项目:apache-tomcat-7.0.73-with-comment    文件:JspRuntimeLibrary.java   
/**
 * 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));

}
项目:jaffa-framework    文件:FunctionGuardTag.java   
/** .//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;
    }
}
项目:jaffa-framework    文件:ComponentGuardTag.java   
/** .//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;
    }
}
项目:beyondj    文件:JspRuntimeLibrary.java   
/**
 * 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));

}
项目:sonar-scanner-maven    文件:TagUtils.java   
/**
 * 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()));
    }
}
项目:ipaas    文件:HtmlTag.java   
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;
}
项目:packagedrone    文件:JspRuntimeLibrary.java   
/**
 * 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));

}
项目:ServletStudyDemo    文件:TagDemo4.java   
@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();
}
项目:Lucee4    文件:ComponentLoader.java   
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);
}
项目:Lucee4    文件:FormatTag.java   
/**
 * 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;
}
项目:ontopia    文件:OtherwiseTag.java   
/** 
 * 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;
}
项目:ontopia    文件:StringTag.java   
/**
 * 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;
}
项目:ontopia    文件:AttributeTag.java   
/**
 * 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;
}
项目:ontopia    文件:AssociationTypeLoopTag.java   
/**
 * 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;
  }

}
项目:Lucee    文件:PageContextUtil.java   
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;
}
项目:Lucee    文件:Renderer.java   
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;
}
项目:Lucee    文件:FormatTag.java   
/**
    * Method called at end of format tag body.
    *
    * @return SKIP_BODY
    */
   @Override
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;
   }
项目:elpi    文件:IteratorTag.java   
@Override
public int doEndTag() {
    try {
        BodyContent body = getBodyContent();

        if (body != null) {
            JspWriter out = body.getEnclosingWriter();
            String bodyString = body.getString();
            body.clearBody();
            out.print(bodyString);
        }
    } catch (IOException e) {
        Debug.logInfo("IteratorTag IO Error", module);
        Debug.logInfo(e, module);
    }
    return EVAL_PAGE;
}
项目:elpi    文件:IteratorHasNextTag.java   
@Override
public int doEndTag() {
    try {
        BodyContent body = getBodyContent();

        if (body != null) {
            JspWriter out = body.getEnclosingWriter();
            String bodyString = body.getString();
            body.clearBody();
            out.print(bodyString);
        }
    } catch (IOException e) {
        System.out.println("IterateNext Tag error: " + e);
    }
    return EVAL_PAGE;
}
项目:elpi    文件:IfTag.java   
@Override
public int doEndTag() {
    try {
        BodyContent body = getBodyContent();

        if (body != null) {
            JspWriter out = body.getEnclosingWriter();
            String bodyString = body.getString();
            body.clearBody();
            //Debug.logInfo("printing string: " + bodyString, module);
            out.print(bodyString);
        }
    } catch (IOException e) {
        Debug.logError(e, "IfTag Error.", module);
    }
    return EVAL_PAGE;
}
项目:elpi    文件:ContentUrlTag.java   
@Override
public int doEndTag() throws JspException {
    HttpServletRequest request = (HttpServletRequest) pageContext.getRequest();

    BodyContent body = getBodyContent();
    String bodyString = body.getString();

    StringBuilder newURL = new StringBuilder();

    appendContentPrefix(request, newURL);
    newURL.append(bodyString);
    body.clearBody();

    try {
        getPreviousOut().print(newURL.toString());
    } catch (IOException e) {
        if (UtilJ2eeCompat.useNestedJspException(pageContext.getServletContext())) {
            throw new JspException(e.getMessage(), e);
        } else {
            Debug.logError(e, "Server does not support nested exceptions, here is the exception", module);
            throw new JspException(e.toString());
        }
    }
    return SKIP_BODY;
}
项目:elpi    文件:IterateNextTag.java   
@Override
public int doEndTag() {
    try {
        BodyContent body = getBodyContent();

        if (body != null) {
            JspWriter out = body.getEnclosingWriter();
            String bodyString = body.getString();
            body.clearBody();
            out.print(bodyString);
        }
    } catch (IOException e) {
        System.out.println("IterateNext Tag error: " + e);
    }
    return EVAL_PAGE;
}
项目:o3erp    文件:IteratorTag.java   
@Override
public int doEndTag() {
    try {
        BodyContent body = getBodyContent();

        if (body != null) {
            JspWriter out = body.getEnclosingWriter();
            String bodyString = body.getString();
            body.clearBody();
            out.print(bodyString);
        }
    } catch (IOException e) {
        Debug.logInfo("IteratorTag IO Error", module);
        Debug.logInfo(e, module);
    }
    return EVAL_PAGE;
}
项目:o3erp    文件:IteratorHasNextTag.java   
@Override
public int doEndTag() {
    try {
        BodyContent body = getBodyContent();

        if (body != null) {
            JspWriter out = body.getEnclosingWriter();
            String bodyString = body.getString();
            body.clearBody();
            out.print(bodyString);
        }
    } catch (IOException e) {
        System.out.println("IterateNext Tag error: " + e);
    }
    return EVAL_PAGE;
}
项目:o3erp    文件:IfTag.java   
@Override
public int doEndTag() {
    try {
        BodyContent body = getBodyContent();

        if (body != null) {
            JspWriter out = body.getEnclosingWriter();
            String bodyString = body.getString();
            body.clearBody();
            //Debug.logInfo("printing string: " + bodyString, module);
            out.print(bodyString);
        }
    } catch (IOException e) {
        Debug.logError(e, "IfTag Error.", module);
    }
    return EVAL_PAGE;
}
项目:o3erp    文件:ContentUrlTag.java   
@Override
public int doEndTag() throws JspException {
    HttpServletRequest request = (HttpServletRequest) pageContext.getRequest();

    BodyContent body = getBodyContent();
    String bodyString = body.getString();

    StringBuilder newURL = new StringBuilder();

    appendContentPrefix(request, newURL);
    newURL.append(bodyString);
    body.clearBody();

    try {
        getPreviousOut().print(newURL.toString());
    } catch (IOException e) {
        if (UtilJ2eeCompat.useNestedJspException(pageContext.getServletContext())) {
            throw new JspException(e.getMessage(), e);
        } else {
            Debug.logError(e, "Server does not support nested exceptions, here is the exception", module);
            throw new JspException(e.toString());
        }
    }
    return SKIP_BODY;
}
项目:o3erp    文件:IterateNextTag.java   
@Override
public int doEndTag() {
    try {
        BodyContent body = getBodyContent();

        if (body != null) {
            JspWriter out = body.getEnclosingWriter();
            String bodyString = body.getString();
            body.clearBody();
            out.print(bodyString);
        }
    } catch (IOException e) {
        System.out.println("IterateNext Tag error: " + e);
    }
    return EVAL_PAGE;
}
项目:class-guard    文件:JspRuntimeLibrary.java   
/**
 * 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));

}
项目:package-drone    文件:JspRuntimeLibrary.java   
/**
 * 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));

}
项目:apache-tomcat-7.0.57    文件:JspRuntimeLibrary.java   
/**
 * 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));

}
项目:apache-tomcat-7.0.57    文件:JspRuntimeLibrary.java   
/**
 * 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));

}
项目:WBSAirback    文件:JspRuntimeLibrary.java   
/**
 * 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));

}
项目:DMWeb    文件:DMWebFragmentBodyTagLibrary.java   
@Override
public int doEndTag() throws JspException
{
   try
   {
      BodyContent bc = this.getBodyContent();
      String body = bc.getString();
      JspWriter out = this.pageContext.getOut();
      out.println("<body>");
      out.print(body);

      JSONStructure jsonStructure = new JSONStructure(0);
      this.marshaller.marschall(this.serializationData, jsonStructure);
      String json = jsonStructure.toString();

      out.println("<script>\nvar bz_davide_dm_widgets = " + json + "</script>");
      out.println("</body>");
      return BodyTagSupport.EVAL_PAGE;
   }
   catch (Exception exxx)
   {
      throw new JspException(exxx);
   }
}
项目:bennu-renderers    文件:MessagesTag.java   
@Override
public int doAfterBody() throws JspException {
    try {
        BodyContent body = getBodyContent();

        if (body != null) {
            JspWriter out = body.getEnclosingWriter();
            out.println(body.getString());
            body.clearBody(); // Clear for next evaluation
        }
    } catch (IOException e) {
        throw new JspException("could not write body", e);
    }

    return goNext(false);
}
项目:ironsites    文件:XSSFilterHTMLTag.java   
@Override
public int doAfterBody() throws JspException {
    BodyContent bodyContent;
    String body;
    JspWriter out;
    try {
        bodyContent = getBodyContent();
        out = bodyContent.getEnclosingWriter();
        body = XSSUtil.filterHTML(getPolicy(), 
                getContext(), 
                bodyContent.getString(), 
                pageContext);
        if (StringUtils.isNotEmpty(body)) {
            out.print(body);
        }
    } catch (IOException ioe) {
        LOG.debug(ioe.getMessage());
        throw new JspException(ioe);
    } finally {
        bodyContent = null;
        body = null;
        out = null;
    }
    return SKIP_BODY;
}
项目:jaffa-framework    文件:CustomTag.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 {
    if (log.isDebugEnabled())
        log.debug(this.NAME+".doAfterBody: START. pageContext="+pageContext+ ", BodyContent="+getBodyContent() );

    if(IBodyTag.class.isInstance(this)) {
        // We should output the body content
        BodyContent bodyContent = getBodyContent();

        if (log.isDebugEnabled())
            log.debug(this.NAME+".doAfterBody: Got Body Size = " +
                    (bodyContent.getString() == null ? "null" : ""+bodyContent.getString().length()));
        try {

            JspWriter out = getPreviousOut();
            writeTagBodyContent(out, bodyContent);
        } catch (IOException ex) {
            log.error(this.NAME + ".doAfterBody(): Error on "+this, ex);
            throw new JspException("Error in " + this.NAME + ".doAfterBody() on "+this);
        }
    }

    if (theBodyShouldBeEvaluatedAgain()) {
        return EVAL_BODY_AGAIN;
    } else {
        return SKIP_BODY;
    }
}
项目:spring4-understanding    文件:AbstractHtmlElementBodyTag.java   
/**
 * The user customised the output of the error messages - flush the
 * buffered content into the main {@link javax.servlet.jsp.JspWriter}.
 */
protected void flushBufferedBodyContent(BodyContent bodyContent) throws JspException {
    try {
        bodyContent.writeOut(bodyContent.getEnclosingWriter());
    }
    catch (IOException e) {
        throw new JspException("Unable to write buffered body content.", e);
    }
}