anchor.diff:              session.removeAttribute(UserAdminUIConstants.USER_LIST_UNASSIGNED_ROLE_CACHE);
               session.removeAttribute(UserAdminUIConstants.USER_LIST_UNASSIGNED_ROLE_CACHE_EXCEEDED);
           }
  -       
  +
           String message = MessageFormat.format(resourceBundle.getString("user.update"), Util.decodeHTMLCharacters(username));
           CarbonUIMessage.sendCarbonUIMessage(message, CarbonUIMessage.INFO, request);
   
   
  -        if(logout){
  +        if (logout) {
   %>
   
   <script type="text/javascript">
  -                window.location.href = "../admin/logout_action.jsp";
  -            </script>
  +    window.location.href = "../admin/logout_action.jsp";
  +</script>
   <%
  -        } else if(finish) {
  -        	%>
  -        	<script type="text/javascript">
  -                location.href = "user-mgt.jsp?ordinal=1";
  -            </script>
  -        	<%
  -        } else if(viewUsers){
  +        } else if (finish) {
   %>
  -            <script type="text/javascript">
  -                location.href = "view-roles.jsp?username=<%=URLEncoder.encode(username)%>";
  -            </script>
  +<script type="text/javascript">
  +    location.href = "user-mgt.jsp?ordinal=1";
  +</script>
  +<%
  +        } else if (viewUsers) {
  +%>
  +<script type="text/javascript">
  +    location.href = "view-roles.jsp?username=<%=URLEncoder.encode(username)%>";
  +</script>
   <%
           } else {
   %>
  -            <script type="text/javascript">
  -                location.href = "edit-user-roles.jsp?username=<%=URLEncoder.encode(username)%>" + "&pageNumber=<%=pageNumber%>";
  -            </script>
  +<script type="text/javascript">
  +    location.href = "edit-user-roles.jsp?username=<%=URLEncoder.encode(username)%>" + "&pageNumber=<%=pageNumber%>";
  +</script>
   <%
           }
       } catch (Exception e) {
  -         String message = MessageFormat.format(resourceBundle.getString("role.list.cannot.update"), Util.decodeHTMLCharacters(username), e.getMessage());
  -         CarbonUIMessage.sendCarbonUIMessage(message, CarbonUIMessage.ERROR, request);
  -        if(viewUsers){
  +
  +        String encodedUsername = "";
  +        String decodedUserName = "";
  +
  +            if(username != null){
  +                encodedUsername = URLEncoder.encode(username);
  +                decodedUserName = Util.decodeHTMLCharacters(username);
  +            }
  +
  +        String message = MessageFormat.format(resourceBundle.getString("role.list.cannot.update"), decodedUserName, e.getMessage());
  +        CarbonUIMessage.sendCarbonUIMessage(message, CarbonUIMessage.ERROR, request);
  +        if (viewUsers) {
   %>
  -            <script type="text/javascript">
  -                location.href = "view-roles.jsp?username=<%=URLEncoder.encode(username)%>";
  -            </script>
  +<script type="text/javascript">
  +    location.href = "view-roles.jsp?username=<%=encodedUsername%>";
  +</script>
   <%
  -        } else {
  +} else {
   %>
  -            <script type="text/javascript">
  -                location.href = "edit-user-roles.jsp?username=<%=URLEncoder.encode(username)%>";
  -            </script>
  +<script type="text/javascript">
  +    location.href = "edit-user-roles.jsp?username=<%=encodedUsername%>";
  +</script>
   <%
           }
       }
   %>
   
   <%!
  -    private String[] addSelectedRoleLists(String[] selectedRoles, Map<String,Boolean> sessionRolesMap){
  +    private String[] addSelectedRoleLists(String[] selectedRoles, Map<String, Boolean> sessionRolesMap) {
           List<String> selectedRolesList = new ArrayList<String>();
  -        if(selectedRoles != null && selectedRoles.length > 0){
  +        if (selectedRoles != null && selectedRoles.length > 0) {
               selectedRolesList = new ArrayList<String>(Arrays.asList(selectedRoles));
           }
  -        if(sessionRolesMap != null){
  +        if (sessionRolesMap != null) {
               Set<String> keys = sessionRolesMap.keySet();
  -            for(String key:keys){
  -                if(sessionRolesMap.get(key) == true && !selectedRolesList.contains(key)){
  +            for (String key : keys) {
  +                if (sessionRolesMap.get(key) == true && !selectedRolesList.contains(key)) {
                       selectedRolesList.add(key);
                   }
               }
  
positive.code:    under the License.
    --%>
  
  <%@page import="org.apache.axis2.context.ConfigurationContext"%>
  <%@page import="org.wso2.carbon.CarbonConstants" %>
  <%@page import="org.wso2.carbon.ui.CarbonUIMessage"%>
  <%@page import="org.wso2.carbon.ui.CarbonUIUtil"%>
  <%@page import="org.wso2.carbon.ui.util.CharacterEncoder" %>
  <%@page import="org.wso2.carbon.user.mgt.ui.UserAdminClient" %>
  <%@ page import="org.wso2.carbon.user.mgt.ui.UserAdminUIConstants" %>
  
negative.code:                 }
              }
          }
          selectedRoles = addSelectedRoleLists(selectedRoles, (Map<String, Boolean>) session.getAttribute("checkedRolesMap"));
          addDeletedRoleLists(deletedList, (Map<String, Boolean>) session.getAttribute("checkedRolesMap"));
  
          if (viewUsers) {
              client.addRemoveRolesOfUser(Util.decodeHTMLCharacters(username), null,
                      deletedList.toArray(new String[deletedList.size()]));
          } else {
  