HTTP request parameters are not available by request.getAttribute()
Solution 1:
Here,
String url = (String) request.getAttribute("url");
you're trying to get a request parameter as a request attribute instead of as a request parameter. This will obviously not do what you want.
You need to get a request parameter as a request parameter, not as a request attribute.
String url = request.getParameter("url");
Unrelated to the concrete problem: you don't seem to be URL-encoding the parameter at all before sending. This will possibly cause other problems, unrelated to this one, when the url
contains special characters. Look at the JS encodeURIComponent()
function, or the data
argument of the $.getJSON()
function. See for more hints also How to use Servlets and Ajax?