{ if (username != null) username = username.trim(); if (username == null || username.length() == 0) { throw new ServletException("Username must not be empty.");
{ if (username != null) username = username.trim(); if (username == null || username.length() == 0) { throw new ServletException("Username must not be empty."); }  String msg = null; try { if (rabean.userExist(username)) { msg = "User '" + username + "' already exists."; } } catch (Exception e) { throw new ServletException("Error checking username '" + username + ": " + e.toString(), e); } if (msg != null) { throw new ServletException(msg); }  return username;
  private final String checkUsername(RAInterfaceBean rabean, String username)    throws ServletException  {    if (username != null) username = username.trim();    if (username == null || username.length() == 0) {      throw new ServletException("Username must not be empty.");    }    String msg = null;    try {      if (rabean.userExist(username)) {        msg = "User '" + username + "' already exists.";      }    } catch (Exception e) {      throw new ServletException("Error checking username '" + username +                                 ": " + e.toString(), e);    }    if (msg != null) {      throw new ServletException(msg);    }    return username;  }