I am developing a webapplication based on JSP. I have a servlet class :
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<String> usernamesList = StudentManager.findAllUsernames();
req.setAttribute("usernames", new Gson().toJson(usernamesList));
}
}
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 ?
Kind regards,
h4