开发者

How to read ServletOutputStream

In my web application, I have two servlets as Servlet A and Servlet B. There is call to Servlet A from browser. Servlet A invokes Servlet B using RequestDispatcher calling include() method.

Servlet B writes some bytes on ServletOutputStream.

Now to the next line of include() method I want to read bytes wrote by Servlet B. How I can?

Abstract 开发者_运维知识库of code is as bellow.

public class A extends HttpServlet {
   protected void doGet(HttpServletRequest request, HttpServletResponse response) {
     RequestDispatcher rd = request.getRequestDispatcher("/B");
     rd.include(request, response);

    // Now here i want to read bytes of ServletOutputStream for further processing
    // How do I?

   }
}

Again I certainly cannot modify code of servlet B. It is predefined. Secondly it is sure that servlet B writes bytes on ServletOutputStream.

Any help is really apprreciated.


You should have a look at HttpServletResponseWrapper. Have a look for more info here and here

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜