title: How to use Spring Security username in Javascript
body: <p>I am trying to access the Spring Source Security user variable ${username} in some JavaScript and it keeps coming back as an empty string.  On a previous page, I am displaying the username with simply ${username}.  From all I can tell, all I need to do to get this in the javascript is: </p>
  
  <pre><code>&lt;c:out value="${username}"/&gt;
  </code></pre>
  
  <p>But in the code below, the generated HTML always has an empty string.  What am I missing?</p>
  
  <pre><code>&lt;%@ page session="false"%&gt;
  &lt;%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%&gt;
  &lt;%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%&gt;
  &lt;%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%&gt;
  &lt;%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%&gt;
  &lt;html xmlns="http://www.w3.org/1999/xhtml"&gt;
  &lt;head&gt;
  &lt;title&gt;The Admin Page&lt;/title&gt;
  &lt;style type="text/css"&gt;
  
      .wideCols .field-radio { width: 5%; }
      .wideCols .field-username { width: 15%; }
      .wideCols .field-firstName { width: 15%; }
      .wideCols .field-lastName { width: 20%; }
      .wideCols .field-email { width: 40%; }
      .wideCols .field-enabled { width: 5%; }
  &lt;/style&gt;
  &lt;/head&gt;
  &lt;body&gt;
      &lt;h1&gt;Users&lt;/h1&gt;
      &lt;spring:url value="/admin/addUser" var="accountUrl" /&gt;
  
      &lt;a href="${accountUrl}"&gt;Add User&lt;/a&gt; 
      &lt;div id="result1"&gt;&lt;/div&gt;
  
      &lt;div id="grid" class="wideCols"&gt;&lt;/div&gt;
      &lt;!-- &lt;button type="button" id="saveNode"&gt;&lt;/button&gt;  --&gt;
  
  
      &lt;script type="text/javascript"&gt;
          require([ "dojo/store/JsonRest",
                    "dojo/_base/declare",
                    "dgrid/OnDemandGrid",
                    "dgrid/Selection", 
                    "dgrid/editor",
                    "dgrid/selector",
                    "dojo/domReady!" 
                  ], function(JsonRest, declare, OnDemandGrid, Selection, editor, selector) {
  
              var userAccountStore = new JsonRest({
                  idProperty : "userAccountId",
                  target : "&lt;c:url value="/userMgr/" /&gt;"
              });
  
              window.grid = new (declare([OnDemandGrid, Selection]))({                
                  store : userAccountStore,           
                  columns:  [ selector({ label: 'radio'}, "radio"),
                              { label: "Username", field: "username"}, 
                              { label: "First Name", field: "firstName"}, 
                              { label: "Last Name", field: "lastName"}, 
                              { label: "Email", field: "email"}, 
                              editor({ label: "Enabled", field: "enabled", autoSave: "true", canEdit: function(object){
                                  return object.username != "&lt;c:out value="${username}"/&gt;";
                              }, }, "checkbox")],
              }, "grid"); 
  
          });
  
      &lt;/script&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>