Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

waitFor to get data from server

 
Fiona Applesmith
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • 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?
 
Mohammed Yousuff
Ranch Hand
Posts: 198
  • Mark post as helpful
  • send pies
  • 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
  • Quote
  • Report post to moderator
java file:


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


jsp file:
 
Salil Vverma
Ranch Hand
Posts: 257
Hibernate Oracle Spring
  • Mark post as helpful
  • send pies
  • 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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic