开发者

How to read ServletOutputStream

开发者 https://www.devze.com 2023-04-04 19:09 出处:网络
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.

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

精彩评论

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

关注公众号