I have a web app developed with JEE
My problem is :I send data from servlet to jsp which is array but I dont know how to read each element :
Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
Connection c = DriverManager.getConnection("jdbc:sqlserver://localhost\\SQL2008R2:99;database=Netos_DB;user=sa;password=123");
Statement statement = c.createStatement();
int xVal;
Float yVal;
String nom;
String name = request.getParameter("nom");
PreparedStatement ps = c.prepareStatement("select * from V502_client where M500_NOM=?");
ps.setString(1, name);
ResultSet resultSet = ps.executeQuery();
while(resultSet.next()){
xVal = resultSet.getInt("Mois");
yVal = resultSet.getFloat("ChiffreAffaire");
nom=resultSet.getString("M500_NOM");
map = new HashMap<Object,Object>(); map.put("x", xVal); map.put("y", yVal);map.put("z",nom); list.add(map);
dataPoints = gsonObj.toJson(list);
}
request.getSession().setAttribute("data", dataPoints);
RequestDispatcher rd = request.getRequestDispatcher("graph.jsp");
rd.forward(request, response);
When I came to my jsp page,I do: <div> ${data} </div>
but that shows me this [{"x":3,"y":2280.0,"z":"3EG"},{"x":6,"y":4200.0,"z":"3EG"}]