0

I am writing a simple webserver for my unity game. The problem is if I do ${list}, it displays the JSON string but if I do it in scriptlet it returns null value.

@RequestMapping(value = "/distance.do")
public ModelAndView distance(CommandMap commandMap) throws Exception {
    ModelAndView mv = new ModelAndView("distanceProc");
    List<Map<String, Object>> list = sampleService.distance(commandMap.getMap());

    JSONObject obj = new JSONObject();

    for(int i = 0; i < list.size(); i++) {
        obj.put("city", list.get(i));
    }

    String jsonString = obj.toString();

    mv.addObject("list", jsonString);

    return mv;
}

distanceProc.jsp

${list}

${list} displays

{"city":{"cityName":"*****","distance":0,"latitude":*****,"cityId":*,"longitude":*****}}

while

<%
String data = request.getParameter("list");
System.out.println("Received Data: " + data);
%>

returns null. Am I missing something?

Hexaholic
  • 3,299
  • 7
  • 30
  • 39
Inacio
  • 127
  • 12

1 Answers1

2

Are you sure that list is http request parameter?

What will the result be on

<%
String data = request.getAttribute("list");
System.out.println("Received Data: " + data);
%>

EL expression ${list} will give you the value of list attribute in one of the page, request, session, and application scopes. If list is really http request parameter and you would like to access it via EL than use ${param.list}.

In case it solved the problem:

Community
  • 1
  • 1
mr.tarsa
  • 6,386
  • 3
  • 25
  • 42