Lato server ho la seguente porzione di codice:
- ....
- JSONArray jArray=new JSONArray();
- JSONObject jObject=new JSONObject();
- while(rs.next()){
- jObject.put("id_p",rs.getInt(1));
- jObject.put("nome", rs.getString(2));
- jArray.add(jObject);
- }
- out.print(jArray);
mandandolo in esecuzione ho verificato che il risultato è il seguente:
- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
- "http://www.w3.org/TR/html4/loose.dtd">
- <html>
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
- <title>JSP Page</title>
- </head>
- <body>
- [{"id_p":1,"nome":"Alien alveare"},{"id_p":2,"nome":"Alien genocidio"}]
- </body>
- </html>
perché mi restituisce come risultato tutto questo codice html? in teoria dovrebbe restituirmi solo jArray no? dove posso aver sbagliato?