Improve company productivity with a Business Account.Sign Up

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 167
  • Last Modified:

JSP Question(Urgent Please)

How can I call a Perl function from my JSP code?
My JSP file is at the directory: "/export/usr/../code/";
The Perl file is in the same directory as the JSP file.

The Perl file name is get_id and it takes a parameter (of type String).

On the command prompt it works like this:
$cd /export/usr/../code/
$./get_id myname
W1234

Now in My JSP (Java code), how can I write a system command?

I need to write something in my JSP code:
String myinput = "Jon";
String ret;
ret = system /export/usr/../code/get_id myinput;
//ret should hold the string "W1234".


How can I write the JSP code above with correct syntax?
Thanks.

0
tooki
Asked:
tooki
1 Solution
 
objectsCommented:
hres an example that runs an external process:
http://www.objects.com.au/java/examples/util/ConsoleExec.do
0
 
tookiAuthor Commented:
Thanks!
The eamples there seemed to be little complex.
It will be helpful to me if I know how to write a line of code in Java that runs an executible on the OS.
In C++ we write system("executiblename anyparameter")..
the same for Java code..

Thanks.
0
 
objectsCommented:
Process p = Runtime.getRuntime().exec(command);
0
The 14th Annual Expert Award Winners

The results are in! Meet the top members of our 2017 Expert Awards. Congratulations to all who qualified!

 
jarasaCommented:
If you can call your pearl from the web why don't just make a response.sendRedirect(URL); ?
Javier
0
 
KuldeepchaturvediCommented:
If I remember correctly, getRuntime.exec() not gonna return any value that process may provide. All it can return is a return code telling if process exited normally.
So it won't do any good in this senario.
I think  you will have to make a URL connection to your Perl function and readout the response from URLConnection
0
 
objectsCommented:
>  All it can return is a return code

It also returns all the stdout, and stderr.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now