0

What I want to archive is I have a.exe file saved in server. This a.exe needs one INT input from 0-10, and the output of it is to create a file for user. And then webpage can show it to users. My question is how can I call the a.exe? My website's back end is created with Java. Where should I put that call for a.exe? How to do that? Or maybe in the first place, is is possible to do it? I don't really care the speed, since there is only one user can use it each time.

Thanks a lot!!!!

user3252009
  • 1
  • 1
  • 1

2 Answers2

0

Look into Common Gateway Interface (CGI).

CGI Programs with Java

Ben Crowhurst
  • 8,204
  • 6
  • 48
  • 78
0

I really don't recommend you set up your web site like this, but if you must, here's how you gather the input from the website:

<form method="POST">
Enter value 0-10: <input name="value" value="0">
<input type="submit" value="Submit">
</form>

Then on your server side, retrieve the input value by looking at the POST variable. I don't know which Java framework you are using, but there's a method to access it.

Then you need to invoke the exe file by redirecting the gathered input to the keyboard input. Run the following command:

ExecuteShellComand obj = new ExecuteShellComand();
String output = obj.executeCommand("myexe.exe < "+inputvalue);

Then use a buffer reader to gather the exe output and forward that to the newly generated HTML page.

Schien
  • 3,855
  • 1
  • 16
  • 29