• Post Reply Bookmark Topic Watch Topic
  • New Topic

JSP and Java wait help

 
shashikant kale
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello All,
Im c++ guy so new to jsp and java.
I need your help on following scenario.
I'm processing one message and generating xml file and storing at some location say some_server/tmp/hello.xml
now as per the requirement,in java im copying that file to my server and im using runtime.exec apis
say 1) cp /some_server/hello.xml /my_server/hello.xml
2) then chaging the mode chmod 777 /my_server/hello.xml
Afterwords I have to show this file in jsp.
point is,step 1 and 2 take some time and it is working fine means copy and change mode too.but in jsp side it is not getting this file..bottom line is jsp is not waiting till the above operation get finish.

I tried all options like....thread.sleep(),since im calling in process.
so i tried process.wait and process.waitFor() but no result.
it is not waiting,

please give me some solution.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65529
105
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"shashjava", please check your private messages for an important administrative matter.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65529
105
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why are you not using Java file I/O for the file operations?
 
shashikant kale
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No I cannt since the xml file is on different server and before processing further I have to copy that file on my local server before displaying.
Thats the reason im using Runtime.getRuntime.exec(cmd) where cmd is the copy command.
 
shashikant kale
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No I cannt since the xml file is on different server and before processing further I have to copy that file on my local server before displaying.
Thats the reason im using Runtime.getRuntime.exec(cmd) where cmd is the copy command.
 
Steve Luke
Bartender
Posts: 4181
22
IntelliJ IDE Java Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by shashkale:
No I cannt since the xml file is on different server and before processing further I have to copy that file on my local server before displaying.
Thats the reason im using Runtime.getRuntime.exec(cmd) where cmd is the copy command.


Is the file visible as a URL on the other server? At very least you should be able to use a URLConnection to read the results from the other server, and File I/O to write it to 'this' server.

If you still feel you need Runtime.exec, be sure to read this article which gives most of the main reasons why the operations seem fail. A must read for anyone using Runtime.exec(). But you shouldn't need Runtime.exec() in this case.

If that still doesn't help you will have to provide more information on how the application fails. What error messages do you get, etc... There could be many reasons for the copying to work but the JSP to be unable to read the results and only more information would help us diagnose the problem.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65529
105
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
"shashkale", you have previously been warned on multiple occasions regarding adjusting your display name to meet JavaRanch standards. This is not optional, and this is your final warning. Adjust your display name to comply with the required standards prior to your next post.

Your display name must be a first and a last name separated by a space character, and must not be obviously fictitious.

Failure to comply will result in the removal of your account.

bear
JavaRanch Sheriff
 
shashikant kale
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For my above problem I debugged the issue and it seems it problem of iframe cache.
here is the code im thinking it will work..your help will be appericiated if there is any issue in below code.

<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
<META HTTP-EQUIV="Expires" CONTENT="-1">

</head>

<script type="text/javascript">
var randomnumber=Math.floor(Math.random()*100000)

document.write('
<iframe src="temp/tempFile?random='+randomnumber+'" name="aframe" width="100%" height="400"></iframe>')

</script>

tempFile - its file which can contain raw text data or xml data which im going to show.
 
shashikant kale
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For my above problem I debugged the issue and it seems it problem of iframe cache.
here is the code im thinking it will work..your help will be appericiated if there is any issue in below code.

<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
<META HTTP-EQUIV="Expires" CONTENT="-1">

</head>

<script type="text/javascript">
var randomnumber=Math.floor(Math.random()*100000)

document.write('
<iframe src="temp/tempFile?random='+randomnumber+'" name="aframe" width="100%" height="400"></iframe>')

</script>

tempFile - its file which can contain raw text data or xml data which im going to show.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!