T
T
tommy_diaver2014-11-03 16:28:51
Java
tommy_diaver, 2014-11-03 16:28:51

Did the PrintWriter work successfully?

Good day.
There is a servlet:

protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    request.setCharacterEncoding("UTF-8");
    response.setCharacterEncoding("UTF-8");
    PrintWriter out = response.getWriter();
    out.println("<some html>");
    out.close();
    }

Let's say this situation, during the execution of out.println(""); the Internet is cut off on the machine whose browser accepts "
Is it possible to handle this situation somehow? What exception should I catch? Tried to catch IOException, no result. out.checkError
()
from which HttpServletRequest came already chopped off?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Malah, 2014-11-13
@tommy_diaver

It is forbidden.
If the server sent an HttpServletResponse, then your code worked correctly and no exceptions will occur. Next, your some html goes over the network via the HTTP protocol (the server has already "fired back" and forgot about the request it just answered). The protocol specification does not imply sending messages to the server that data has been successfully received.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question