1

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"}]

imanealami
  • 189
  • 5
  • 13
  • Is there any configuration or jars to add to work with this ,because I'm getting an error : L'uri absolu: [http://java.sun.com/jsp/jstl/core] ne peut être résolu dans le fichier web.xml ni dans les fichiers jar déployés avec cette application – imanealami Feb 28 '20 at 13:22
  • yes you need to add `<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>` this at top of your jsp page .Also check [this](https://stackoverflow.com/a/2401001/10606400) answer. – Swati Feb 28 '20 at 13:30
  • I already add this taglib but I'm getting this msg :L'uri absolu: [java.sun.com/jsp/jstl/core] ne peut être résolu dans le fichier web.xml ni dans les fichiers jar déployés avec cette application – imanealami Feb 28 '20 at 13:35
  • To resolve above error check [this](https://stackoverflow.com/questions/8701307/the-absolute-uri-http-java-sun-com-jsp-jstl-core-cannot-be-resolved-in-either) post as well as [this](https://stackoverflow.com/a/2401001/10606400) answer. – Swati Feb 28 '20 at 13:49
  • Ok i worked with c library but i'm getting an error: javax.el.PropertyNotFoundException: La propriété x n'a pas été trouvée sur le type [java.lang.String] – imanealami Feb 28 '20 at 14:35
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/208713/discussion-between-swati-and-imanealami). – Swati Feb 28 '20 at 14:43

0 Answers0