I have some problems making the exception do that i want!. I have created a servlet, which i want to handle all exceptions. My class building for this scenario that i need help too you see under here:
Servlet: This exception handling is only for 1 method,
try {
completed = func.addNewOperator(userId, name, ini, cpr, password, role);
}catch (Exception e) {
Error = "There was a problem with database access";
response.sendRedirect("SystemError.jsp?Error_resultat=" + Error);
} catch (IOException e) {
Error = "Error found with connection";
response.sendRedirect("SystemError.jsp?Error_resultat=" + Error);
} catch (RuntimeException e) {
Error = "Error found with entered values";
response.sendRedirect("SystemError.jsp?Error_resultat=" + Error);
} catch (Exception e) {
Error = "Serious error found!";
response.sendRedirect("SystemError.jsp?Error_resultat=" + Error);
The func.addNewOperator is called in my function class:
Function:
A small example from my function method you see under here:
public boolean addNewOperator(String userId, String name, String ini, String cpr, String password, String role ) throws Exception {
int id = Integer.parseInt(userId);
}
So lets say if it can't parse it to and integer, it should throws the exception to my servlet, but this is not working. I want to throw the exception to the servlet, and then the servlet should send a response to open SystemError.jsp with an error message as parameter.
Can anyone see if i forgot something??