In server side app.js file I would run one jar file ,which gives the result and I store that in one variable.Now I had a route /index in my app where Iam calling html and .js file for client side from my app.js file.Now I want to display the result variable from my server side on to the client side html.How can I display that result on to my html in one textbox on button click.
app.js(main file)-server side
var exec = require('child_process').exec;
var child = exec('java -jar ./helloworld.jar',
function (error, stdout, stderr){
console.log('Output -> ' + stdout);
var jardata=stdout;//In jardata Im having my response from jarfile
console.log(jardata,"jar out...");
if(error !== null){
console.log("Error -> "+error);
}
});
module.exports = child;
app.get('/index',function(req,res){
res.sendFile(path.join(__dirname+'/public/index.html'));
});
index.html(clientside)
<body>
<div style="margin:100px;">
<div class="jumbotron" style="padding:40px;">
<h1>Hello!!!</h1>
<div>
<button type="submit" onclick="callJar();">Call</button>
<input type="text" id="textbox">
</div>
</div>
</div>
</body>
index.js(client side js)
function callJar(){
console.log("Hello");
var text="Hello";
var textbox=document.getElementById('textbox');
textbox.value=text;
}
Now how can i make jardata display in that text box can someone help!!
via user7350714
No comments:
Post a Comment