code_junkie

How do I report an error midway through a chunked http repsonse if I'm willing to close the connection?

Nov 11th, 2011
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.69 KB | None | 0 0
  1. <script type="text/javascript"> alert("Processing failed!"); </script>
  2.  
  3. public class Servlet extends HttpServlet {
  4. public static final int ARRAY_SIZE = 65536;
  5. private static final int SEND_COUNT = 100000;
  6.  
  7. protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, java.io.IOException {
  8.  
  9. String testData = "This is a fairly long piece of test text, running on and on and on, over and over.";
  10.  
  11. final ServletOutputStream outputStream = response.getOutputStream();
  12. for (int i = 0; i < SEND_COUNT; ++i) {
  13. outputStream.println(testData);
  14. }
  15. throw new ServletException("Break it now");
  16. }
  17. }
Add Comment
Please, Sign In to add comment