I came across the same problem before and get this one from a message board....It worked for so it should work for you as well..
The problem with JSPs (and HTTP in general) is there is a clear separation between code on the client server and code on the client.
That is, you cannot generally have code running on each end depending on each other. A request is sent to the server, it processes the request and a response is sent back to the client.
The best way I've encountered to do this is to use an intermediate 'Please Wait' page. Essentially the client sends a request to a 'fake processing servlet', this servlet returns a 'please wait' page and sends the original request to the real processing servlet.
The advantage here is that the 'Please wait' page is the one that is displayed while the long processing takes place.
<code>
<!-- START PAGE -->
<!-- This is the page where you enter the details -->
<form action="FakeServlet">
<input type="text" name="username">
<input type="submit">
</form>
<!-- END -->
//-- FakeServlet
//this servlet can parse but not process the data
...start stuff
getRequestDispatcher("pleaseWait.jsp"

.
forward(request,response);
//-- END
<!-- pleaseWait.jsp -->
<!-- This is the page where the form is ACTUALLY submitted --> PLEASE WAIT <!-- this is the message shown while the page submits -->
<form name="auto" action="FakeServlet" action="ProcessServlet">
<input type="hidden" name="username" value="<%=request.getParameter("username"

%>">
</form>
<!-- this script submits the form AFTER it has been completely loaded -->
<script>
document.auto.submit();
</script>
<!-- END -->
//-- Process Servlet
//and finally do the stuff that takes a long time
for(int i=0;i<10000000;i++) {
//etc
}
//-- END
</code>
Libaax
Hakuna Matata....
