tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Alfred von Campe" <alf...@turboworx.com>
Subject RE: Calling a servlet from Perl
Date Fri, 16 May 2003 20:30:21 GMT
I can't even figure out how to pass the parameters to the
servlet as shown in the sample Java code.  All libwww-perl
examples I found do something like this:

  use LWP::UserAgent;
  my $ua = new LWP::UserAgent;
  my $req = new HTTP::Request POST => "http://localhost:8080/path/to/servlet";
  my $res = $ua->request($req);
  if ($res->is_success)
  {
    print "It worked!\n"
  }
  else
  {
    print "Sorry, try again\n";
  }

How do I pass my "%directory=" + pwd + "%args=" + arguments + "%"
to the servlet?  I'm not even sure that I should be using the
HTTP::Request object.

Alfred


-----Original Message-----
From: John Turner [mailto:tomcat-user@johnturner.com]
Sent: Friday, May 16, 2003 4:22 PM
To: Tomcat Users List
Subject: Re: Calling a servlet from Perl



What is it, exactly, that isn't working?

John

On Fri, 16 May 2003 16:14:14 -0400, Alfred von Campe <alfred@turboworx.com> 
wrote:

> I'm sure someone must have done this already, but I did not get very
> far with Google searches today.  I think what I'm trying to do is pretty
> straightforward, and although I'm a long time UNIX/Perl user, I'm new to
> Tomcat and servlets.
>
> In a nutshell, I want to invoke a servlet from Perl.  This servlet 
> expects
> some parameters separated by a percent symbol (%) and then runs some 
> program
> based on the parameters received.  It may or may not send the results 
> back to
> the caller. I have a working Java example that invokes this servlet.  
> Here are
> the relevant code snippets:
>
> String url = new String("http://localhost:8080/path/to/servlet");
> serviceurl = new URL(url);
> URLConnection conn =  serviceurl.openConnection();
> conn.setDoOutput(true);
> PrintWriter out = new PrintWriter(conn.getOutputStream());
> String appToRun = new String ("%directory=" + pwd + "%args=" + arguments 
> + "%");
> out.write(appToRun);
> out.close();
> InputStream in = conn.getInputStream();
> InputStreamReader modin = new InputStreamReader(in);
> result = parseFromReader(modin);
> modin.close();
>
> I have downloaded and installed the latest libwww-perl library (5.69), 
> but
> I can't figure out how to call this servlet.  I'd appreciate any examples
> that will point me in the right direction.  Even the raw protocol 
> exchange
> would be helpful.  If I can understand what's going on between Tomcat and
> the client, I can implement it in Perl (using straight sockets and 
> avoiding
> the use of libwww-perl if necessary).
>
> Thanks,
> Alfred
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tomcat-user-help@jakarta.apache.org
>
>



-- 
Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/

---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: tomcat-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tomcat-user-help@jakarta.apache.org


Mime
View raw message