Win a copy of The Journey To Enterprise Agility this week in the Agile and Other Processes forum! And see the welcome thread for 20% off.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Jeanne Boyarsky
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
Sheriffs:
  • Paul Clapham
  • Junilu Lacar
  • Knute Snortum
Saloon Keepers:
  • Ron McLeod
  • Ganesh Patekar
  • Tim Moores
  • Pete Letkeman
  • Stephan van Hulst
Bartenders:
  • Carey Brown
  • Tim Holloway
  • Joe Ess

Wait Thread ??  RSS feed

 
Author
Ranch Hand
Posts: 399
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
I have a servlet which loads some data to the database from a text file & even executes some other queries on the loaded data.
But as the data as increased, the connection to the server expires, how do I go around this problem, I thought of running some thread during the process which say "Your DATA is being transferred", is this the right way ??
Hope I am clear.
TIA
MB
PS. Welcome AUTHORS !!
 
Ranch Hand
Posts: 8934
Firefox Browser Java Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Do you want to display some temporary page?
[ January 28, 2004: Message edited by: Pradeep Bhat ]
 
Sheriff
Posts: 6920
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The usual approach to this is to return a "please wait" page immediately, while starting the processing as a background thread. Typically this "please wait" page will use a meta refresh tag to wait for a specified time, then attempt fetch a "results" page.
Does that make sense, or do you need more detail?
 
Author
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As mentioned above, the common way to sovle this problem is with a 'wait' page . Kevin and I provide an explicit example of this in the book, e.g.
---- snip -----
Auto-Refresh/Wait Pages
Another response header technique that is uncommon but helpful is to send a wait page or a page that will auto-refresh to a new page after a given period of time. This tactic is helpful in any case where a response might take an uncontrollable time to generate, or for cases where you want to ensure a brief pause in a response. The entire mechanism revolves around setting the Refresh response header(25). The header can be set using the following:

Where time is replaced with the amount of seconds, the page should wait, and url is replaced with the URL that the page should eventually load. For instance, if it was desired to load http://127.0.0.1/foo.html after 10 seconds of waiting, the header would be set as so:

Auto-refreshing pages are helpful because they allow for a normal pull model, waiting for a client s request, to push content. A good practical use case
----- snip ----
And there is a reference to a footnote or two that point to more information about the Refresh header and how it is supported in HTTP 1.0/1.1 and amongst the common web browsers.
 
Ranch Hand
Posts: 204
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a problem with this refresh code. I put the refresh code line in a servlet and it only execute after the redirect line code which exist in my code. I dont know where to place the code. In my servlet there is a loop that takes quite some time to execute. How should I place the code?
 
Ranch Hand
Posts: 3178
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Originally posted by rollin park:
I have a problem with this refresh code. I put the refresh code line in a servlet and it only execute after the redirect line code which exist in my code. I dont know where to place the code. In my servlet there is a loop that takes quite some time to execute. How should I place the code?


Try to put it at the beginning of ur servlet's method, even before the loop so that the header has been set at the very beginning... Hope it helps...
 
michael yue
Ranch Hand
Posts: 204
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Originally posted by Ko Ko Naing:

Try to put it at the beginning of ur servlet's method, even before the loop so that the header has been set at the very beginning... Hope it helps...



hi again
The wait page still won't display after i put it at top. I try to put in thread but to no avail. It keeps displaying the input page until it redirect to new page.Here is my code
Thread thread = new Thread();
thread.start();
//Include the Wait Page which should be displayed before the transaction starts
res.setHeader("Refresh", "1; URL=https://"+host+"/webjos/CVN/wait.html");
//execute the method that takes time example: insert 10000 records (in a for loop)
thread.stop();
if success
redirect to new page
END
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!