Help someone to guess. The situation is as follows:

There is some kind of page (say index.jsp) on which they should display blocks with information. We should load this information from a DB, through Java Servlet. But at the same time I do not want to click on any buttons to send a POST request, which is to pull out this data. I wish that when you go to the page, infa itself was pulled out of the database and displayed in jsp. At the same time, this same infa can also display the jsp page in other pages.

    1 answer 1

    If you need to receive data from the servlet, but you need to open the page (jsp) through the Servlet , and add all the data to the request. The jsp page will access this variable.

      List<Map> usersList = User.findAll(); request.setAttribute("list", usersList); request.getRequestDispatcher("/WEB-INF/index.jsp").forward(request, response); 

    If the jsp page opens directly, you can use the java bean .

     <jsp:useBean id="users" class="bean.Users" scope="request" ></jsp:useBean> .... <% List users = users.findAll(); %> 

    Or you can load the information using JavaScript ( ajax ), sending requests when loading the page, hanging up an event when loading the document (without pressing any buttons).

    And how to get data from the database, it is not much another question, and everything is sown from the database itself.