Apache2::Request doesn't work as expected

Discussion in 'Perl Misc' started by kwan, Mar 5, 2010.

  1. kwan

    kwan Guest

    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
     
    kwan, Mar 5, 2010
    #1
    1. Advertising

  2. kwan

    smallpond Guest

    On Mar 5, 6:31 pm, kwan <> wrote:
    > 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.
     
    smallpond, Mar 6, 2010
    #2
    1. Advertising

  3. kwan

    John Bokma Guest

    smallpond <> writes:

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


    Not true

    --
    John Bokma j3b

    Hacking & Hiking in Mexico - http://johnbokma.com/
    http://castleamber.com/ - Perl & Python Development
     
    John Bokma, Mar 6, 2010
    #3
  4. kwan

    kwan Guest

    On Mar 6, 11:59 am, smallpond <> wrote:
    > On Mar 5, 6:31 pm, kwan <> wrote:
    >
    >
    >
    > > 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 displayform"
    > > 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.


    It doesn't related with that.
     
    kwan, Mar 6, 2010
    #4
  5. kwan

    Guest

    On Sat, 6 Mar 2010 09:59:11 -0800 (PST), smallpond <> wrote:

    >Single quotes are not used in html. It should be:

    I could care less.

    >Spaces are excluded by HTTP. It should be encoded as

    I don't know web stuff, just html. Does http exclude spaces?

    -sln
     
    , Mar 7, 2010
    #5
  6. kwan

    Guest

    Re: [OT] HTML standard (was Apache2::Request doesn't work as expected)

    On Sat, 06 Mar 2010 19:46:05 -0600, Tad McClellan <> wrote:

    >smallpond <> wrote:
    >
    >
    >> Single quotes are not used in html.

    >
    >
    >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
     
    , Mar 7, 2010
    #6
  7. kwan

    kwan Guest

    Re: HTML standard (was Apache2::Request doesn't work as expected)

    On Mar 6, 9:23 pm, wrote:
    > On Sat, 06 Mar 2010 19:46:05 -0600, Tad McClellan <> wrote:
    > >smallpond <> wrote:

    >
    > >> Single quotes are not used in html.

    >
    > >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


    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.
     
    kwan, Mar 7, 2010
    #7
  8. kwan

    Guest

    Re: HTML standard (was Apache2::Request doesn't work as expected)

    On Sat, 6 Mar 2010 19:31:17 -0800 (PST), kwan <> wrote:

    >On Mar 6, 9:23 pm, wrote:
    >> On Sat, 06 Mar 2010 19:46:05 -0600, Tad McClellan <> wrote:
    >> >smallpond <> wrote:

    >>
    >> >> Single quotes are not used in html.

    >>
    >> >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

    >
    >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
     
    , Mar 7, 2010
    #8
  9. kwan

    kwan Guest

    Re: HTML standard (was Apache2::Request doesn't work as expected)

    On Mar 6, 9:58 pm, wrote:
    > On Sat, 6 Mar 2010 19:31:17 -0800 (PST), kwan <> wrote:
    > >On Mar 6, 9:23 pm, wrote:
    > >> On Sat, 06 Mar 2010 19:46:05 -0600, Tad McClellan <> wrote:
    > >> >smallpond <> wrote:

    >
    > >> >> Single quotes are not used in html.

    >
    > >> >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

    >
    > >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


    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.
     
    kwan, Mar 8, 2010
    #9
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Keith Patrick
    Replies:
    2
    Views:
    3,671
    Keith Patrick
    Nov 16, 2005
  2. Alex Buell
    Replies:
    6
    Views:
    324
    Alex Buell
    Feb 23, 2006
  3. thomas
    Replies:
    23
    Views:
    1,958
    Andrey Tarasevich
    Feb 22, 2008
  4. Angus
    Replies:
    8
    Views:
    324
    James Kanze
    Jun 18, 2009
  5. Mc Lauren Series
    Replies:
    11
    Views:
    965
    BootNic
    Feb 12, 2010
Loading...

Share This Page