How do I display data from Database while loading the JSP Page

Discussions

Web tier: servlets, JSP, Web frameworks: How do I display data from Database while loading the JSP Page

  1. There is a situation, I want to display few rows from the database table on to my JSP page while the JSP page is getting loaded. I want this to happen throught a servlet, which I am using as a controller. How to accomplish this without actually submitting the JSP page.
  2. Put the following code into your JSP:

    <% out.flush() %>

    That will transmit all the output generated by your JSP up to that point to your client. Be warned; you can get some flakey behavior with this. Some potential problems:

    1. Once you have flushed some output, the engine can no longer perform redirections, which can mess up error reporting if an error occurs later in the page.

    2. If your output is part of an HTML table, the browser may do funny things rendering partial tables.
  3. Look at this article in Oreilly network. It might be related to what you are trying to do
    http://www.onjava.com/pub/a/onjava/2003/06/11/jsp_progressbars.html