• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Wait Thread ??

 
Author
Posts: 399
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 8945
Firefox Browser Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Do you want to display some temporary page?
[ January 28, 2004: Message edited by: Pradeep Bhat ]
 
Sheriff
Posts: 7001
6
Eclipse IDE Python C++ Debian Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic