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

Asked

Viewed 945 times

1

I am developing a good HTML5 Hybrid mobile app and my backend will be done with Java and Mysql.

I’m using Phonegap and the same to generate the APP needs my files to be extension .html .css .js, to generate the installation file, with this my business rules are in the backend in pages .jsp connecting to the database. The question is how to make the result obtained on a page in the backend Ex: resultado.jsp appears on a page with HTML EX extension: mostra-resultado.html.

I know I could do something with Ajax but I still can’t visualize the construction of it, someone can give me a light or an example.

It follows more or less the idea, this here is only for a light to the concept, has 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>
  • Apparently I didn’t understand your question. I also didn’t understand your reply to my answer. Consider editing your question so more people can try to help you.

1 answer

1

It’s not necessarily your answer, but most html-based mobile applications within the application interact with business rules through services in REST. It is nothing new this concept and yet you manage to obey the MVC.

Imagine 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 recover users in 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 port part of it to mobile devices, some people just create an executable per platform and call the web/site application through an iframe (in the case of android for example, Webview¹)

¹ - 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 a history, zoom in and out, perform text searches and more

  • is an alternative, but using iframe would not be a good practice since I intend to create a scalable application. but I already see a light.

  • I edited the answer and put the quote of what a Webview is. The adjective iframe was just to contextualize a component, it has no relation to html iframe. What is a scalable application for you ? Since the "client" would be the application and the "server" (where your business is) is already highly disabled from any resource.

  • I understood now, had understood how iframe html. when said scalable thought but by the side $business. Grateful.

  • Scalability is not linked to business$: http://pt.wikipedia.org/wiki/Escalability

Browser other questions tagged

You are not signed in. Login or sign up in order to post.