• 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

waitFor to get data from server

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am trying to build an application where I hit a button from a jsp page, sending me to a servlet that uses runtime.exec to run a sql query on the server, then return the results to be displayed on the same page. Right now, i call proc.runtime.exec("get data"), then proc.waitFor(), then I forward(request, response) to the original page. Right now, this is working when i call runtime.exec on a very fast command, such as "pwd," but it is not working for my command which takes slightly longer to run - it redirects before the process has finished. Shouldn't waitFor() let the process terminate before forwarding the request? If not, are there alternatives I should be using?
 
Ranch Hand
Posts: 198
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
does the page is not showing the results for the command which takes more time to process. Servlets are sync process, so it has to wait untill the internal process has to complete.....

Can you post your sample code which you are trying ???

Yousuff

 
Fiona Applesmith
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
java file:


Note that the "pwd" process gives me the desired behavior.


jsp file:
 
Ranch Hand
Posts: 257
Hibernate Oracle Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey,
Could you please let us from to which package the class Runtime and Process belongs. I could not find it in standard java api.
You can try using wait and notify function to resolve this issue.
 
If you settle for what they are giving you, you deserve what you get. Fight for this tiny ad!
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic