hi,
as per
servlet response API specification, if we will try to call one of the method response.getWriter() or response.getOutputStream() while the other one is already invoked then it will throw an
IllegalStateException so if we want to know that the other method is already invoked, or we want to be safe before invoking response.getWriter() or response.getOutputStream(), put the code in a try/catch block, and don't put any other code inside this block.
like:
PrintWriter out=null;
try {
out = response.getWriter();
}
catch(IllegalStateException e)
{
System.out.println("response.getOutputStream() is already called");
}