+ /**
+ * Calls {@link #submit(PrintWriter, HttpServletRequest)} while catching and
+ * displaying errors ({@link GigiApiException}), and re-outputing the form
+ * via {@link #output(PrintWriter, Language, Map)}.
+ *
+ * @param out
+ * the target to write the form and errors to
+ * @param req
+ * the request that this submit originated (for submit and for
+ * language)
+ * @return as {@link #submit(PrintWriter, HttpServletRequest)}: true, iff
+ * the form succeeded and the user should be redirected.
+ */
+ public boolean submitProtected(PrintWriter out, HttpServletRequest req) {
+ try {
+ boolean succeeded = submit(out, req);
+ if (succeeded) {
+ return true;
+ }
+ } catch (GigiApiException e) {
+ e.format(out, LoginPage.getLanguage(req));
+ }
+ output(out, LoginPage.getLanguage(req), new HashMap<String, Object>());
+ return false;
+ }
+