Try making this JSP into a Servlet.
That way you will know for certain it isn't writing/committing anything to the response.
Its all
java code anyway. No reason for it to be in a JSP.
Responses get committed once you start writing the response. That means you can't forward/redirect once you have started returning an answer.
By default JSP pages have a buffer that gives you a bit of leeway. You can start output, and then forward/redirect - it will just clear the buffer and start from "scratch"
Cases where you get this error
- the buffer fills up and is flushed (default Buffer is 8k)
- the buffer explicitly gets flushed
In terms of fixing the problem
1 - rewrite as a servlet to eliminate possible HTML being output from this JSP page..
2 - move the forward/redirect logic further up so that it runs before the buffer is executed.
3 - another thing to watch out for is if you forward/redirect to another resource,
you should not do any other output in a JSP