Solved

JSP Question(Urgent Please)

Posted on 2004-03-29
8
157 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
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
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.

 
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: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

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

Suggested Solutions

Title # Comments Views Activity
Can I clean log of  running tomcat 7 server ? 3 127
getting param value 7 58
best way to search/remove a file from an EAR file 3 112
withoutString  challenge 40 208
This article explains the steps required to use the default Photos screensaver to display branding/corporate images
ConnectWise and their customers need to ensure critical alerts automatically reach the right person at the right time. MSP superheros efficiently respond to these alerts key is providing automatic, intelligent alerting that generates a complete audi…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

860 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