• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

How to call a cgi/perl script from jsp/java bean

 
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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
 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Prkash,

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.

Thanks,
Vignesh
 
Ranch Hand
Posts: 161
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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.
 
when your children are suffering from your punishment, tell your them it will help them write good poetry when they are older. Like this tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic