0

I am trying to understand these line, which are written in a jsp page:

<%@ page import="com.x.VoltDAOImpl" %>
<%! 
              VoltDAOImpl voltDao = new VoltDAOImpl(); 
Map<String , List<HashMap<String,String>>> returnList=  null;
     List<HashMap<String,String>> orderDetailsList1=  null;
orderDetailsList1 = returnList.get("order_details");

JSONArray jsonArray = new JSONArray(orderDetailsList1);

%>

I'm a complete newbie to jsp and javascript, but I'm reading online and getting things done. What I understand from the above lines is that, it's importing from VoltDAOImpl class (calling the class which has some database), creating a HashMap orderDetailsList1 that gets "order_details". But, I don't what to use this jsp. I want to simply call this class in a javascript file and get this orderDetailsList1 as a json. I know, that I can convert some json string to json object using JSON.parse, but how do I call this class and get the order_details as a json string in the first place??

I'm so confused. Please help!!!

Angad
  • 213
  • 2
  • 5
  • 12
  • create a controller, that will access/use VoltDAOImpl, that your AJAX(javascript) will communicate with, which will return a JSON object which you will parse in your jsp. http://stackoverflow.com/questions/18073849/get-a-json-object-from-a-http-response and http://stackoverflow.com/questions/11129286/get-json-from-httpresponse – Omasu Plus Oct 18 '16 at 02:16
  • *"convert some json string to json object"* - Not to a "json object", just to an "object" (because [there's no such thing as a JSON object](http://benalman.com/news/2010/03/theres-no-such-thing-as-a-json/)). – nnnnnn Oct 18 '16 at 02:27
  • @OmasuPlus As I said I'm a complete newbie so I don't understand what you wrote. – Angad Oct 19 '16 at 01:45
  • @Angad i dont know, your understanding of the code is correct, that gave me the impression that you know how to code java... try reading on JAVA Web Application tutorials then to get you started... learn about servlets, jsp, http response-request-session etc... if you dont help yourself then how can others help you... – Omasu Plus Oct 19 '16 at 03:20

0 Answers0