natarajan01 has asked for the wisdom of the Perl Monks concerning the following question:

Hi All, can anyone help me, how perl communicate with JSP? is it possible? If yes please Thanks in advance Natarajan

Replies are listed 'Best First'.
Re: PERL with JSP interaction
by polettix (Vicar) on Apr 10, 2007 at 08:19 UTC
    The fact is that you don't specify at what level you want a Perl-JSP interaction.

    If it's the "basic" client-server interaction, you can probably benefit from LWP::UserAgent and its powerful descendant WWW::Mechanize. Both let you build up a flexible "client-side" to interact with the JSP "server-side", even if the second is more suited to mimic a browser interaction with the server (and you get both of them, actually, because WWW::Mechanize is a subclass of LWP::UserAgent).

    Flavio
    perl -ple'$_=reverse' <<<ti.xittelop@oivalf

    Don't fool yourself.

      ++polettix. This is a snippet of code I use for my perl client to get results from a tomcat server using LWP::UserAgent (but modified here to pull from the monastery).

      #!/usr/bin/perl use strict; use warnings; use LWP::UserAgent; my $url = "http://www.perlmonks.org/?displaytype=xml;node_id=609084"; # Create a user agent my $ua = LWP::UserAgent->new; # Set the user agent string - useful for spelunking logs $ua->agent( "myapp" ); # Get the data my $res = $ua->get( $url ); # Check the outcome of the response if( $res->is_success ) { print $res->content, "\n"; }
      I do this all the time ... the perl cgi-script (or mod_perl handler) will parse params, construct a url, fetch data (normally xml), and then format the fetched data.

      -derby

      Update: removed the extraneous use of HTTP::Request ... thanks polettix

Re: PERL with JSP interaction
by Moron (Curate) on Apr 10, 2007 at 15:53 UTC
    It depends on who is calling who or if both are running in parallel. If JSP is calling perl,
    Runtime.getRuntime().exec(...)
    can run any shell command, including invocation of a Perl program and give it arguments in the command line which Perl picks up as @ARGV.

    If it's the other way round, there are many ways for Perl to invoke the .jsp, including using ``, system(), but the most comprehensive is IPC::Run3.

    If it's parallel, then maybe communicate through a named pipe.

    -M

    Free your mind

A reply falls below the community's threshold of quality. You may see it by logging in.