If you have already sent the response to the client by calling out.flush() and after that trying to use sendError or forward, it will give
IllegalStateException This is a code for sending the jar file to client
public void doGet(HttpServletRequest request,HttpServletResponse response)throws IOException,ServletException{
response.setContentType(�application/jar�);
ServletContext ctx=getServletContext();
InputStream is=ctx.getResourceAsStream(�bookCode.jar�);
int read=0;
byte[] bytes=new byte[1024];
OutputStream os=response.getOutputStream();
while((read=is.read(bytes))!=-1){
os.write(bytes,0,read);
}
os.flush();
RequestDispatcher view=request.getRequestDispatcher(�result.jsp�);
view.forward(request,response);
os.close();
}
Here os.flush() cause the response to be sent to the client and that point this response is done.Now if you try view.forward(request,response) , it will give IllegalStateException
same is with sendError()