title: How to use GSON and display information in JSP file
body: <p>I am developing a webapplication based on JSP. I have a servlet class : </p>
  
  <pre><code>package managesystem;
  
  import java.util.List;
  
  import javax.servlet.http.HttpServlet;
  import javax.servlet.http.HttpServletRequest;
  import javax.servlet.http.HttpServletResponse;
  
  import com.google.gson.Gson;
  
  public class getUsernamesServlet extends HttpServlet{
  
  /**
   * 
   */
  private static final long serialVersionUID = 1L;
  
     public void doGet(HttpServletRequest req, HttpServletResponse resp){
        List&lt;String&gt; usernamesList = StudentManager.findAllUsernames();
        req.setAttribute("usernames", new Gson().toJson(usernamesList));
  
     }
  
  }
  </code></pre>
  
  <p>My question is as follows : How do I check with Ajax if a usernames is still available (if it isn't present in the list) ? How do I get the JSON information that the servlet writes to the request, in for example register.jsp using Ajax ?</p>
  
  <p>Kind regards,</p>
  
  <p>h4</p>