This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes JSP and the fly likes jsp wont display until loop has completed Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » JSP
Bookmark "jsp wont display until loop has completed" Watch "jsp wont display until loop has completed" New topic
Author

jsp wont display until loop has completed

Chris Garrison
Ranch Hand

Joined: Jun 13, 2002
Posts: 44
I have a jsp that I want to display a "please wait while your query processes" message once a query is 'submitted.'
After displaying this (in the same .jsp), I want to loop like (pseudo code) :
while (queryStatus != finished){
sleep(a little while);
}
//once query is complete
<jsp:forward to results.jsp to see results>
The problem is: the page wont display until the loop completes (in other words, the "please wait ..." string never comes up. It does nothing until the queryStatus = finished - then if forwards to the result.jsp
Is this by design or am I doing something wrong? What can I do?
[ November 04, 2003: Message edited by: Chris Garrison11 ]

May the force be with you, always.
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60785
    
  65

Of course this won't work. The whole purpose of a JSP is to compose the HTML page to send to the client browser. By placing a wait in this page, you simply delay the sending of the HTML to the browser.
This very subject has been discussed on numerous occasions within this (and perhaps the Servlet) forum. A search should lead you to those previous discussions.
bear


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by Bear]
Chris Garrison
Ranch Hand

Joined: Jun 13, 2002
Posts: 44
I know this forum is free, but does the attitude cost extra?
Bear Bibeault
Author and ninkuma
Marshal

Joined: Jan 10, 2002
Posts: 60785
    
  65

If you are reading attitude, you are reading wrong.
Perhaps a different approach: the way a JSP works is to buffer up some output to send to the browser. Any Java in the JSP runs on the server to build up this text buffer to send to the client. When the buffer is full, or the JSP is done executing, the output is sent to the browser. So if you put a wait in the page, you merely delay the building of the buffer.
If you haven't found what you are looking for after searching through the previous discussions on this topic, please feel free to ask further questions.
bear
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: jsp wont display until loop has completed
 
Similar Threads
RMI + Thread: perform searching on different worker PCs
Does not display message on JDialog
how to display waiting/loading messages until data is displayed to the user
please wait message using javascript
please wait message using javascript