RequestDispatcherOptions options = new RequestDispatcherOptions();
options.setReplaceSelectors(" ");
request.getRequestDispatcher(request.getResource(), options).forward(request, response);
} else {
response.setContentType("application/json");
JSONObject json = new JSONObject();
try {
json.put("success", false);
JSONObject messages = new JSONObject();
for (Map.Entry<String, List<String>> entry : vr.getFailureMessages().entrySet()) {
String key = entry.getKey();
JSONArray errors = new JSONArray();
for (String message : entry.getValue()) {
errors.put(message);
}
messages.put(key, errors);
}
json.put("messages", messages);
response.getWriter().print(json.toString());
response.setStatus(400);
} catch (JSONException e) {