I am trying to write a web client (running as a
servlet), that sends a request to a remote server and then captures the response, parse the response body for relevant data, and then move on to another page.
I had implemented this in the past by writing a web-client in ASP/"Perlscript". Where the Perscript sends the "request" to the remote server, and then parses the "response" at leisure. A sample code is below.
Any suggestions how I could implement the same in the Servlet world?
example from the past:
----------
file: responseParser.asp
----------
<%@LANGUAGE="PERLSCRIPT"%>
<%
use HTTP::Request::Common qw(POST);
use HTTP::Request::Common qw(GET);
use LWP::UserAgent;
my $ua = new LWP::UserAgent;
my $varURL = "http://www.cnn.com";
my $res = $ua->request( POST $varURL );
$_ = $res->{_content};
#NOTE: $_ has all the content of the response body
my $dataFound;
if ( /Interstingdata\"(.*?)\"End/s ){
$dataFound = $1;
}
$Response->Write( "found your data: " .$dataFound. "<br>" );
%>