How to call information in an html from a .jsp page

1

I'm developing a good hybrid5 HTML5 mobile app and my backend will be done with Java and MySQL.

I am using PhoneGap and the same one to generate the APP needs that my files are of extension .html .css .js , to generate the installation file, so my business rules are in the backend on .jsp pages that connect to the database. The question is how to make the result obtained on a page in the backend ex: resultado.jsp appear on a page with HTML extension EX: mostra-resultado.html .

I know I could do something with Ajax but I still can not see the build of it, can someone give me a light or an example.

More or less the idea, this is just to give the light a concept, no commitment to the truth.

<!--Exemplo da página html-->
<html>
    <button>Chama a lista 1</button>
    <button>Chama a lista 2</button>
    <div>
        <!--Resultado da lista que foi verificada na página.jsp-->
    </div>
</html>


<!--Exemplo da página .jsp-->
<jsp>
    if(lista1){
    <!--Mostra o resultado da lista 1 -->
    }else if(lista2){
    <!--Mostra o resultado da lista 1 -->
    }
</jsp>
    
asked by anonymous 02.10.2014 / 16:18

1 answer

1

It is not necessarily your answer, but most mobile applications with html contained within the application interact with business rules through services at REST . This concept is not new and yet you can obey the MVC .

Imagine that you have a service that lists users in the url (which returns a JSON ): http://domain.com/usuario/listar

With the use of the jQuery API, you would retrieve users this way:

$.getJSON("http://domain.com/usuario/listar", function(usuarios) {
        $.each(usuarios, function(indice, usuario) {
            $('body').append(indice + ": " +  usuario.nome + "<br>");
        });
    });
});

Now if you already have your web application and do not want to take part of it for mobile devices, some people just create one executable per platform and call the web application / site through an iframe (in the case of android eg < a Webreview ¹)

  

¹ - A View that displays web pages. This class is the basis upon which you can roll your own web browser or simply display some online content within your Activity. It uses the WebKit rendering engine to display web pages and includes methods to navigate forward and backward through history, zoom in and out, perform text searches and more

    
02.10.2014 / 18:22