I want to call a CGI/perl script from my jsp or java bean . The script is lying on a diferent server . How do i execute the script from my server . Please help , Thanx and regards , Prakash
Joined: Jun 26, 2006
Have your problem got resolved. i am also same kind of situation.
I also need to call cgi perl script from my java/servelet application get result back to java/servelts.
If your problem got resolved . Could you please help me in this.
Joined: Jun 06, 2006
I have had this issue once, to read a resource from a different technology from within a servlet filet (or a normal servlet too). in my case my servlet (filter) needed to call a facility in a proprietary product that was running on the same server, and was also calling JSP based service. But the concept is the same for your situation, to have a JSP page call the CGI on a different server. Assuming that you can build a URL with get parameters and you are able to interpret the results of the CGI in a meaningful way in your code, this approach may also work for you.
What I did was create an HTTP URL connection from inside my request to physically retreive the HTTP URL request of the other system, and then interpret the results into my handling.
here is a snippet of my code that would make a HTTP URL call out to the other server. I spent most of the time generating the URL to invoke the call and pass parameters from a servlet filter configuration. The resulting page was an XML file, so i stuffed it into an XML parser.
Disclaimer: this solution may be somewhat hackish, but was the best for my situation. This may have some performance and scaleablility issues with large amounts of users or heavy site loads, as every request that uses it would in turn create a HTTP request to another web server, which causes the original request to block until the nested htttp request is finished. You may also be able to use a HTTP client toolkit, such as jakarta commons http client instead of the java.net one like I used.
Error: Keyboard not attached. Press F1 to continue.