Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

JSP Question(Urgent Please)

Posted on 2004-03-29
8
Medium Priority
?
165 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
6 Comments
 
LVL 92

Accepted Solution

by:
objects earned 400 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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

In this post, I will showcase the steps for how to create groups in Office 365. Office 365 groups allow for ease of flexibility and collaboration between staff members.
Following on from our article on "The Murky World of Consent and opt in", we thought we would issue some helpful guidance, not only on consent itself but knowing what information you are capturing, what you are doing with this data and how you can p…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Screencast - Getting to Know the Pipeline
Suggested Courses
Course of the Month6 days, 13 hours left to enroll

782 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