Apache2::Request doesn't work as expected

K

kwan

Hello,

I wrote a mod_perl to check some of the value that users select. The
script will generate a form according to the selection from the user.
There are three forms that are dynamically generated according to the
selection,
in the "display form", there are links to the "add form" and
"modify form".
in the "add form", there are links to the "display form" and
modify form".
in the "modify form", there are links to the display form"
and "add from".

In each link, it is like this:
http://hostname:80/mainform?selection=display
http://hostname:80/mainform?selection=modify
http://hostname:80/mainform?selection=add

within the form, I also have the submit form for user to submit the
content to the server.
the submit form is: <input type="submit" name="selection"
value='Add Content'>

Before, when I use "use CGI" package I can use "param", and the form
will be generate and query according to the user submit.
Code:
my $selection = lc (param('selection'));
if ($selection eq "add content") { }# work with CGI, but
not with Apache2::Request::param
elsif ($selection eq "modify") {} # work both
elsif ($selection eq "add") {} # work both
elsif ($selection eq "display"){} # work both
elsif ($selection eq "modify content"){} # work with CGI,
but not with Apache2::Request:param

when using CGI, I can get the "param" work according to the user
selection. However, when I replace to the following code by using
Apache2::Request, when user select modify form, and submit the form.
the $r->param('selection') is failed to identify the "modify content"
value.

my $rq = new Apache2::Request($r);
my $selection = lc ($rq->param('selection'));

I've followed the perldoc Apache2::Request, it isn't much infor about
the
behavior of the Apache2::Request, as it is mimic the CGI.

Thank
 
S

smallpond

Hello,

I wrote a mod_perl to check some of the value that users select. The
script will generate a form according to the selection from the user.
There are three forms that are dynamically generated according to the
selection,
         in the "display form", there are links to the "add form" and
"modify form".
         in the "add form", there are links to the "display form" and
modify form".
         in the "modify form", there are links to the display form"
and "add from".

In each link, it is like this:
                   http://hostname:80/mainform?selection=display
                   http://hostname:80/mainform?selection=modify
                   http://hostname:80/mainform?selection=add

within the form, I also have the submit form for user to submit the
content to the server.
the submit form is: <input type="submit" name="selection"
value='Add Content'>

Before, when I use "use CGI" package I can use "param", and the form
will be generate and query according to the user submit.
Code:
          my $selection = lc (param('selection'));
          if ($selection eq "add content") {    }# work with CGI, but
not with Apache2::Request::param
          elsif ($selection eq "modify") {}  # work both
          elsif ($selection eq "add") {}       # work both
          elsif ($selection eq "display"){}   # work both
          elsif ($selection eq "modify content"){} # work with CGI,
but not with Apache2::Request:param

when using CGI, I can get the "param" work according to the user
selection. However, when I replace  to the following code by using
Apache2::Request, when user select modify form, and submit the form.
the $r->param('selection') is failed to identify the "modify content"
value.

my $rq = new Apache2::Request($r);
my $selection = lc ($rq->param('selection'));

I've followed the perldoc Apache2::Request, it isn't much infor about
the
behavior of the Apache2::Request, as it is mimic the CGI.


Single quotes are not used in html. It should be:
<input type="submit" name="selection" value="Add Content">

Spaces are excluded by HTTP. It should be encoded as
"Add%20Content" in the URL. You can print the params to see
what you are getting.
 
K

kwan

Single quotes are not used in html.  It should be:
<input type="submit" name="selection" value="Add Content">

Spaces are excluded by HTTP.  It should be encoded as
"Add%20Content" in the URL.  You can print the params to see
what you are getting.

It doesn't related with that.
 
S

sln

Single quotes are most certainly allowed in HTML.


http://www.w3.org/TR/html4/intro/sgmltut.html#h-3.2.2
^^
So xml is a fix on html and '' is grandfathered in.
By default, SGML requires that all attribute values be delimited
using either double quotation marks (ASCII decimal 34) or single
quotation marks (ASCII decimal 39).

And now, the king god SGML speaks it, deems it, it!
It is now in stone, and let no man take us'eth er a under.
So beith, as it was and will be, <pause>, or forever hold your peace.. <pause>,
Amen!

So sayeth we all !! Aye...

-sln
 
K

kwan

     ^^
So xml is a fix on html and '' is grandfathered in.




And now, the king god SGML speaks it, deems it,   it!
It is now in stone, and let no man take us'eth  er a under.
So beith, as it was and will be,  <pause>, or forever hold your peace..<pause>,
Amen!

So sayeth we all !! Aye...

-sln

Probably, it is how Apache2::Request handle the parameters. I am not
sure it is a bug, but hopefully I can find the solution.
I don't really want to mix with Apache2::Request with CGI script.
CGI::param is working fine with the problems that I have described,
but when Apache2::Request::param just doesn't understand the request
at all.
 
S

sln

Probably, it is how Apache2::Request handle the parameters. I am not
sure it is a bug, but hopefully I can find the solution.
I don't really want to mix with Apache2::Request with CGI script.
CGI::param is working fine with the problems that I have described,
but when Apache2::Request::param just doesn't understand the request
at all.

I won't say I could handle or fix your problem. I would say I have been
paid a lot of money to fix problems a lot of experts can't.

-sln
 
K

kwan

I won't say I could handle or fix your problem. I would say I have been
paid a lot of money to fix problems a lot of experts can't.

-sln

I got the answer. It was the problem with the form.
<form method="POST" action="/app3">

</form>

I need action in order for the Apache2::Request::param to be able to
query the parameter.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,020
Latest member
GenesisGai

Latest Threads

Top