java - Create system call to run my python code in jsp file -



java - Create system call to run my python code in jsp file -

what i'm trying create jsp page phone call python code. i'm trying phone call python code scheme function in jsp. i'm creating page create cross domain phone call page jsp page.

can tell me how can create scheme phone call python code? run next command execution of python code in terminal:

root@user:/folder # python p111.py

i tried next code

<html> <body> hello! time <script> process qq=runtime.exec(new string[] { "./dsapce/webapps/jspui/p111.py", "p111.py", }, null, new file("./dsapce/webapps/jspui/p111.py")); qq.waitfor(); </script> </body> </html>

something not correct..

take @ java's runtime.exec(), or processbuilder if need fancier.

but jython. lets run python code in java.

and avoid putting business logic in jsps; it's frowned upon—they're improve templating. set forwarding code in servlet.

here's example, have create sure python can found. might have set absolute path in rather "python":

runtime.exec(new string[] { "python", "p111.py", }, null, new file("./path/where/p111/lives"));

if java isn't running root (which shouldn't be), python has (which shouldn't), better, it's os-dependent:

runtime.exec(new string[] { "sudo", "python", "p111.py", }, null, new file("./path/where/p111/lives"));

these homecoming process object. if want wait python finish , see if operation success, process.waitfor() , check value. if want grab output or provide input, you'll need process.getinput/output/errorstream().

if script runs , completes , care performance, bad model because process creation expensive.

java python jsp user-interface webpage

Comments

Popular posts from this blog

java - How to set log4j.defaultInitOverride property to false in jboss server 6 -

c - GStreamer 1.0 1.4.5 RTSP Example Server sends 503 Service unavailable -

Using ajax with sonata admin list view pagination -