Looking for advice on best practices for implementing a yes or no question with AJAX requests.
Open to feedback if I make any missteps along the way.
- I have a specific Servlet (AjaxServlet?) designated to handle all AJAX requests
- AjaxServlet is mapped to /ajax/*, meaning URLs like /ajax/getDataFromServer will be managed by it
- My doGet override function consists of a lengthy if/elseif chain that evaluates request.getPathInfo() each time
- Each if block in doGet manages a distinct URL call (/ajax/getDataFromServer)
For returning JSON responses, I've been manually constructing these strings. Are there any lightweight JSON libraries available? I'm considering creating a custom ArrayListJson class with a toJson() method, but I feel like this functionality may already exist somewhere.