Custom Exception in jsp

<%! class CustomException extends Exception { String value="This is a custom Exception"; public String toString() { return "Custom Exception: " + value; } CustomException(String v) { value = v; } } void fetchException(String value) throws CustomException { if(value != ""){ throw new CustomException(value); } } %> <% try { fetchException("This is a custom Exception"); fetchException(""); } catch (CustomException e) { out.println("Exception: " + e); } %>