I have a servlet which has a variable which holds a JSON string.
JSONObject obj = new JSONObject();
obj.put("parameter", jsonList);
request.setAttribute("jsonstring", obj.toString());
RequestDispatcher rd = request.getRequestDispatcher("/file.jsp");
rd.forward(request, response);
Now I am forwarding my request and response objects to a JSP page which contains a JS file. How can I access the value of jsonstring variable inside the JS file.As I need to parse my JSON string further using jQuery.
I tried doing this in my JS file as I saw in some of the posts online.But it seems like its not working for me.
var test = '<%=request.getAttribute("jsonstring")%>'
Kindly guide me on the same.Thanx.