// In GwtHostingServlet's doGet() method...
writer.append("<html><head>");
writer.append("<script type=\"text/javascript\" src=\"sample/sample.nocache.js\"></script>");
// Open a second <script> tag where we will define some extra data
writer.append("<script type=\"text/javascript\">");
// Define a global JSON object called "info" which can contain some simple key/value pairs
writer.append("var info = { ");
// Include the user's email with the key "email"
writer.append("\"email\" : \"" + userService.getCurrentUser().getEmail() + "\"");
// End the JSON object definition
writer.append(" };");
// End the <script> tag
writer.append("</script>");
writer.append("</head><body>Hello, world!</body></html>");
public static native String getEmail() /*-{
return $wnd.info['email'];
}-*/;