Solved

JSP Question(Urgent Please)

Posted on 2004-03-29
8
155 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
default methods vs abstract class 1 109
how to exclude a file using regex 5 117
doubleChar java challenge 7 102
Looking for some programs to resell or buy source codes 1 75
Note: This is the second blog post in a series on email clearinghouses (https://www.xmatters.com/alert-management/blog-email-has-failed-us?utm_campaign=70138000000ydLoAAI&utm_source=exex&utm_medium=article&utm_content=blog-post).   Every month t…
Some code to ensure data integrity when using macros within Excel. Also included code that helps secure your data within an Excel workbook.
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
Internet Business Fax to Email Made Easy - With  eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, f…

910 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now