• 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:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Sleep In Jsp

 
Ranch Hand
Posts: 243
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear Ranchers,

I wish to make the jsp wait for sometime around 5 seconds,
how should i implement sleep in this.
 
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And why you want it like that? I mean, can you please tell us what you are trying to achieve?
 
Ranch Hand
Posts: 2308
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It would give you the similar effect as putting sleep in the service method of servlet.

Why do you want your processing to wait ?
 
anand phulwani
Ranch Hand
Posts: 243
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear Ranchers,

The Jsp Calls A PHP which in turn resizes a phtograph and writes it to disk,the jsp writes out an img tag referring to that photo written on to disk,now sometimes the image is not displayed and a cross is displayed against it,which shows that before the PHP had written the file to disk,the jsp wrote the img tag and the browser rendered it.I want to wait the jsp for 2-3 seconds before it writes out the tag,although it wont completely remove the possibility of the image not loading,but it will surely minimize it,here is the code


[ June 21, 2007: Message edited by: anand phulwani ]
 
Sheriff
Posts: 13411
Firefox Browser VI Editor Redhat
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A couple ideas:

Java Advanced Imaging (JAI) makes it pretty easy to resize images from within your java code. Going this route would eliminate the need for JSP altogether.

Have your PHP script return something.
Then use UrlConnection's getContent or getInputStream method to read the response from the PHP call. This will force your JSP page to wait until the PHP page has finished processing before moving to the next line.

Just having your JSP sleep for an arbitrary number of seconds, as you've said, will either force the user to wait longer than necessary or, worse, if the image takes longer, still leave you with the same problem you have now.
 
anand phulwani
Ranch Hand
Posts: 243
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dear Ben,

Thanks a tonne,i was thinking for the the 2 point,that would be lot easier,JAI was failing with some images,i tried this earlier.Still
big thanks to you.
 
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
anand i think JAI solution should work...
but its not.. then why don't you use java script, to load the image after complete loading of entire file.. and mean while popup a nice processing or in prorcess layer.. to facilitate users.. if image is so critical..

i know JS solutions should be used as last solution..
did you try Thread.sleep(). isn't it working..?
 
Adeel Ansari
Ranch Hand
Posts: 2874
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Originally posted by Faisal Ahmed Siddiqui:
did you try Thread.sleep(). isn't it working..?



As already said, "Just having your JSP sleep for an arbitrary number of seconds" doesn't sound like a rational thing to do.
 
Consider Paul's rocket mass heater.
    Bookmark Topic Watch Topic
  • New Topic