[prev in list] [next in list] [prev in thread] [next in thread] 

List:       apache-modperl
Subject:    Re: bouncing a request  back from a mod_perl script?
From:       Stas Bekman <stas () stason ! org>
Date:       2004-01-26 19:47:54
Message-ID: 40156EEA.2020804 () stason ! org
[Download RAW message or body]

Paul Tomsic wrote:
> Is it possible to take a request object 
> (from a posted html form) and
> bounce it to something else?
> For instance, we've got a form that submits to a perl
> script (running
> under mod_perl)
> We do something w/ the form data that's posted, but we
> then need
> access to that posted form content elsewhere (within a
> java servlet).
> Can we collect that original form post within the perl
> script and
> redirect it back to a java servlet as, essentially, a
> new request to
> the servlet?
> Currently we're writing the request to a file as a
> name/value pair property file, and redirecting to the
> servlet w/ a querystring of the file's location.
> this doesn't seem like the best way however.

I'd take a look at the Apache::Request for Apache2, which now installs itself 
as a filter and can read the body and (I suppose could be made optionally to 
leave it there).

> I've tried the following, but I seem to lose the
> contents of the
> request:
> 
> package MyTest;
> 
> use Apache::Constants qw(M_POST M_GET OK
> SERVER_ERROR);
> use HTTP::Request::Common qw(POST);
> use LWP::UserAgent;

the above 2 lines seem to be irrelevant.

> use strict;
> 
> sub handler {
>  my $r = shift;
>  my $content = $r->content;
>  $r->method("POST");
>  $r->method_number(M_POST);
>  $r->headers_in->unset("Content-length");
>  $r->args($content);
>  $r->internal_redirect_handler("/servlet/tester");
> }
> 1;
> 
> it'll redirect back to the servlet named "tester"
> okay, but the request obj is empty once it gets back
> to my servlet.

See:
http://perl.apache.org/docs/1.0/guide/snippets.html#Reusing_Data_from_POST_request

__________________________________________________________________
Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/     mod_perl Guide ---> http://perl.apache.org
mailto:stas@stason.org http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com


-- 
Reporting bugs: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html

[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic