B4J Question webapp bind jqwidgets with jsp

billyrudi

Active Member
Licensed User
Longtime User
how i can bind a jqwidjets witn jsp?
i have this situation
B4X:
  var source =
  {
  datatype: "json",
  datafields: [
  { name: 'Ora' },
  { name: 'P_Rete' },
            { name: 'P_Batteria' }
  ],
  url: 'p.jsp',
  };

but i can not able to make my webapp to run jsp file.
if i run it with jetty directly it works correctly.

my jsp is so made
B4X:
<%@ page import="java.lang.*"%>
<%@ page import="java.sql.*"%>
<%@ page import="com.google.gson.*"%>
<%
    Integer IdSolar = 100;
    if (null != request.getParameter("IdSolar"))
    {
        try
        {
            IdSolar = Integer.parseInt(request.getParameter("IdSolar"));
        }
        catch (NumberFormatException nfe) {}
        {
        }       
    }
    // database connection
    // "jdbc:mysql://localhost:3306/solargs" - the database url of the form jdbc:subprotocol:subname
    Connection dbConnection = DriverManager.getConnection("jdbc:mysql://localhost:3306/solargs", "root", "raspberry");
    // retrieve necessary records from database
    String sql = "SELECT  DATE_FORMAT(MIN(concat(data, ' ' , ora)),'%H:%i') AS ora,sum(P_Batteria_W10) /COUNT(idSolarEclipse) as P_Batteria,sum(P_Rete) /COUNT(idSolarEclipse) as P_Rete FROM SolarEclipse where idsolar=?  GROUP BY ROUND(UNIX_TIMESTAMP(concat(data, ' ' , ora)) / 300), IdSolar  order by idSolarEclipse  asc";
    PreparedStatement stmt = dbConnection.prepareStatement(sql);
    stmt.setInt(1, IdSolar);
           
    ResultSet solareclipse = stmt.executeQuery();
   
    // format returned ResultSet as a JSON array
    JsonArray recordsArray = new JsonArray();
   
    while (solareclipse.next()) {
        JsonObject currentRecord = new JsonObject();
        currentRecord.add("Ora", new JsonPrimitive(solareclipse.getString("Ora")));
        currentRecord.add("P_Batteria", new JsonPrimitive(solareclipse.getString("P_Batteria")));
        currentRecord.add("P_Rete", new JsonPrimitive(solareclipse.getString("P_Rete")));
        recordsArray.add(currentRecord);
    }
   
    out.print(recordsArray);
    out.flush();
%>
 

billyrudi

Active Member
Licensed User
Longtime User
Erel can you help me to use with embedded jetty also jsp extension if it is enabled? If it is not can you enable it?
Regards Paolo
 
Upvote 0
Top