0

Is there a JSP tag that allows that part of the page to process asynchronously? If not is there a way to create one?

Something like the following:

<Util:Asynchronous>
    <%
        DataSource source = ...

    %>
</Util:Asynchronous>
... rest of page

I don't want to have to wait for the data source to finish before processing the rest of the page.

Thanks.

nikdeapen
  • 1,581
  • 3
  • 15
  • 27

2 Answers2

0

You need to use AJAX. Also it is bad coding practice to put your data access commands in your JSP pages. Very susceptible to hacks, not to mention performance hits.

mel3kings
  • 8,857
  • 3
  • 60
  • 68
-1

The servlet container must wait that you are page is entirely rendered before sending it back to the client. Thus your requirement makes no sense for me.

If a part of the page takes too much time to process, you could use Ajax to load a portion of your page. There is already pages at StackOverflow about Ajax.

Community
  • 1
  • 1
LaurentG
  • 11,128
  • 9
  • 51
  • 66
  • Yes, it must wait till all operations complete to send the page back but I have two parts of the page that both require complex queries in the database and are independent of each other and want to execute them concurrently. – nikdeapen Jun 20 '13 at 04:31
  • In that case, I think the JSP is not the right place to handle this. That's a job for your controller. – LaurentG Jun 20 '13 at 04:50