You are viewing a plain text version of this content. The canonical link for it is here.
Posted to modperl@perl.apache.org by Paul Tomsic <pt...@yahoo.com> on 2004/01/25 23:49:44 UTC
bouncing a request back from a mod_perl script?
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'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;
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.
Thoughts or help greatly appreciated.
thx
__________________________________
Do you Yahoo!?
Yahoo! SiteBuilder - Free web site building tool. Try it!
http://webhosting.yahoo.com/ps/sb/
--
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
Re: bouncing a request back from a mod_perl script?
Posted by Stas Bekman <st...@stason.org>.
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