Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Sleep In Jsp  RSS feed

 
anand phulwani
Ranch Hand
Posts: 242
  • 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.
 
Adeel Ansari
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?
 
Rahul Bhattacharjee
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: 242
  • 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 ]
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • 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: 242
  • 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.
 
Faisal Ahmed Siddiqui
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.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!