Tuesday, June 19, 2012

File Upload Comment

/**
 * This method allows a subclass to override to send another more suitable
 * reply. 
 * 
 * Can't just say resp.sendError(); subclass might want to send a non-error
 * reply, so that 'onload' handlers in forms can know about the problem,
 * which is needed to do hidden upload processing using an iframe, which is
 * the only kind that works on ie8 for file uploads. 
 * 
 * This _still_ won't cover all errors in file upload forms, though. (Or is
 * there an onsubmiterror or something that I don't know about?)
 */
protected void cantHandleRequest(HttpServletRequest request,
  final HttpServletResponse resp, int code, String string) {
 try {
  resp.sendError(400, string);
 } catch (IOException e) {
  throw new RuntimeException(e.getMessage(), e);
 }
}
There's still around 10-15% of users on IE8, this is just for them.

No comments:

Post a Comment