you have already forwarded the response in catch block:
RequestDispatcher dd = request.getRequestDispatcher("error.jsp");
dd.forward(request, response);
so, you can not again call the :
response.sendRedirect("usertaskpage.jsp");
because it is already forwarded (committed).
So what you can do is: keep a string to assign where you need to forward the response.
String page = "";
try {
} catch (Exception e) {
page = "error.jsp";
} finally {
page = "usertaskpage.jsp";
}
RequestDispatcher dd=request.getRequestDispatcher(page);
dd.forward(request, response);