简体   繁体   中英

How to get the HTML content from HttpServletResponse?

I have managed to setup a filter for the servlet on tomcat, but the HttpServletResponse only has functions to get the response headers, not the actual HTML response itself. Some reading told me that I have to make a wrapper class but I don't know how to go about this. After a lot of head wracking, I decided to post this on stackoverflow.

How can I retrieve the HTML content from the HttpServletResponse? I need to save it as a text file.

You need to implement HttpServletRequestWrapper interface, especially methods getWriter and getOutputStream and then provide that class to the doFilter method. At the end you will dump contents of the buffer to the file.

Check a bit similar problem here response wrapper to convert all output to uppercase

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM