My Google Web Toolkit (Multipart) Form is set up to post a file to my servlet. In the event of an error in the servlet, I return an error message. If everything goes smoothly, I send back a JSON string.
...
response.setContentType("text/html");
response.setCharacterEncoding("UTF8");
response.getWriter().write(out.toString());
} catch (FileUploadException e) {
response.sendError(500, e.getMessage());
} catch (Exception e) {
response.sendError(500, e.getMessage());
}
The issue arises when trying to handle this on the client side. I need to determine whether the submission was successful or not, and how to access error messages from exceptions in the client-side code.
@UiHandler("form")
void submitComplete(SubmitCompleteEvent event)
{
...