Caros, já quebrei a cabeça mas não consegui solucionar esse problema!
Nesse código, porque eu não consigo fazer normalmente o RequestDispatcher de dentro do catch?
E como eu conseguiria fazer adequadamente?
protected void doGet(HttpServletRequest request,
HttpServletResponse response) throws ServletException,
IOException {
String acao = request.getParameter("acao");
String idString = request.getParameter("id");
Long id = null;
if (idString != null) {
id = Long.parseLong(idString);
}
try {
if (acao.equals("excluir") && id != null) {
excluir(id, request, response);
} else if (acao.equals("carregar") && id != null) {
carregar(id, request, response);
}
} catch (RuntimeException rte) {
rte.printStackTrace();
request.setAttribute("erro", rte.getMessage());
RequestDispatcher rd = request
.getRequestDispatcher("/erro.jsp");
rd.forward(request, response);
}
}