H
hiwa
In the doGet() method of a servlet, we do:
(1)out.println(simpleMessage);
(2)out.flush();
(3)Do a time consuming task
(4)When the task is finished, we call reqDispatcher.forward()
to display other resource.
The problem is as follows:
If we don't call flush(), simpleMessage doesn't get displayed
before going to other resource.
However, if we call flush(), reqDispatcher.forward() doesn't
work. The error message says "forward() not allowed after buffer
has committed."
If we use sendRedirect() instead of forward(), resulting error
message is the same.
Can't ther be a workaround for the problem?
(1)out.println(simpleMessage);
(2)out.flush();
(3)Do a time consuming task
(4)When the task is finished, we call reqDispatcher.forward()
to display other resource.
The problem is as follows:
If we don't call flush(), simpleMessage doesn't get displayed
before going to other resource.
However, if we call flush(), reqDispatcher.forward() doesn't
work. The error message says "forward() not allowed after buffer
has committed."
If we use sendRedirect() instead of forward(), resulting error
message is the same.
Can't ther be a workaround for the problem?