Jump to content

Usando Json url servlet para html table


Recommended Posts

Com este json array no servlet obtenho o array(de um banco em outra classe) com sucesso, porem queria implementa-lo em uma table html bootstrap atraves do js ou jquery,ajax usando o endereco do servlet como parametro de busca para listar os dados na table, alguem tem alguma ideia de como realizar, tentei de varias formas porem sem sucesso.

http://localhost:8089/proj/Servletteste

protected void processRequest(HttpServletRequest request, HttpServletResponse response)
    throws ServletException, IOException, SQLException {
      response.setContentType("application/json");
      response.setCharacterEncoding("UTF-8");
      CDAO enf = new CDAO();
      JsonObject jsonObject = new JsonObject();
     JsonArray jsonArray = enf.getListar();
       jsonObject.add("TITULO DO JSON", jsonArray);
       System.out.println(jsonObject);
      PrintWriter out = response.getWriter();
     out.println(jsonObject);    }

Exemplo do json retornado do servlet:

{
  "TITULO DO JSON": [
    {
      "AG": "X",
      "PAC": "PAC 1",
      "EX": "X D T",
      "AT": 1,
      "CONT": 0,
      "NUM": "1"
    },
    {
      "AG": "T",
      "PAC": "PAC 2",
      "EX": "T D C",
      "AT": 0,
      "CONT": 0,
      "NUM": "2"
    }
  ]
}

 

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now


×
×
  • Create New...