Solved

JSP Question(Urgent Please)

Posted on 2004-03-29
8
160 Views
Last Modified: 2010-04-01
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
Comment
Question by:tooki
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
8 Comments
 
LVL 92

Accepted Solution

by:
objects earned 100 total points
ID: 10708360
hres an example that runs an external process:
http://www.objects.com.au/java/examples/util/ConsoleExec.do
0
 

Author Comment

by:tooki
ID: 10708641
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
 
LVL 92

Expert Comment

by:objects
ID: 10708683
Process p = Runtime.getRuntime().exec(command);
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 6

Expert Comment

by:jarasa
ID: 10711908
If you can call your pearl from the web why don't just make a response.sendRedirect(URL); ?
Javier
0
 
LVL 19

Expert Comment

by:Kuldeepchaturvedi
ID: 10717389
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
 
LVL 92

Expert Comment

by:objects
ID: 10718181
>  All it can return is a return code

It also returns all the stdout, and stderr.
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Invest in your employees with these five simple steps to improve employee engagement and retention.
Containers like Docker and Rocket are getting more popular every day. In my conversations with customers, they consistently ask what containers are and how they can use them in their environment. If you’re as curious as most people, read on. . .

710 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question