ServletRequest.getParameter question

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Steve

    #1

    ServletRequest.getParameter question

    Hi,

    I'm using ServletRequest. getParameter(), but how do I tell the difference a
    parameter in the query part of a URL and a posted parameter (e.g. an input
    field of a form where method="post").

    Is there anything like the PHP equivalent of $_GET[] and $_POST[] which can
    differentiate between parameters in a URL and posted parameters.

    Thanks very much.

    PS. I'm using the J2EE 1.4 API

    --
    Regards,
    Steve

    "...which means he created the heaven and the earth... in the DARK! How good
    is that?"

  • Hal Rosser

    #2
    Re: ServletRequest. getParameter question


    "Steve" <root@127.0.0.1 > wrote in message
    news:C0816F20.5 911%root@127.0. 0.1...[color=blue]
    > Hi,
    >
    > I'm using ServletRequest. getParameter(), but how do I tell the difference[/color]
    a[color=blue]
    > parameter in the query part of a URL and a posted parameter (e.g. an input
    > field of a form where method="post").
    >
    > Is there anything like the PHP equivalent of $_GET[] and $_POST[] which[/color]
    can[color=blue]
    > differentiate between parameters in a URL and posted parameters.
    >
    > Thanks very much.
    >
    > PS. I'm using the J2EE 1.4 API
    >
    > --
    > Regards,
    > Steve
    >
    > "...which means he created the heaven and the earth... in the DARK! How[/color]
    good[color=blue]
    > is that?"
    >[/color]
    look at the doGet and doPost methods-
    do either one and have it call the other one - passing the request and
    response object


    Comment

    • Steve

      #3
      Re: ServletRequest. getParameter question

      On 8/5/06 01:23, in article J8w7g.34377$iB2 .33715@bignews4 .bellsouth.net,
      "Hal Rosser" <hmrosser@bells outh.net> wrote:
      [color=blue]
      >
      > "Steve" <root@127.0.0.1 > wrote in message
      > news:C0816F20.5 911%root@127.0. 0.1...[color=green]
      >> Hi,
      >>
      >> I'm using ServletRequest. getParameter(), but how do I tell the difference a
      >> parameter in the query part of a URL and a posted parameter (e.g. an input
      >> field of a form where method="post").
      >>[/color]
      > look at the doGet and doPost methods-
      > do either one and have it call the other one - passing the request and
      > response object[/color]

      That's what I thought initially, but what if I POST the url
      '/webapp/servlet?param=v alue'

      There is no way (AFAICT) to tell whether 'param' was in the URL or a posted
      parameter?



      --
      Regards,
      Steve

      "...which means he created the heaven and the earth... in the DARK! How good
      is that?"

      Comment

      • Questman

        #4
        Re: ServletRequest. getParameter question

        Steve wrote:[color=blue]
        > On 8/5/06 01:23, in article J8w7g.34377$iB2 .33715@bignews4 .bellsouth.net,
        > "Hal Rosser" <hmrosser@bells outh.net> wrote:
        >
        >[color=green]
        >>"Steve" <root@127.0.0.1 > wrote in message
        >>news:C0816F20 .5911%root@127. 0.0.1...
        >>[color=darkred]
        >>>Hi,
        >>>
        >>>I'm using ServletRequest. getParameter(), but how do I tell the difference a
        >>>parameter in the query part of a URL and a posted parameter (e.g. an input
        >>>field of a form where method="post").
        >>>[/color]
        >>
        >>look at the doGet and doPost methods-
        >>do either one and have it call the other one - passing the request and
        >>response object[/color]
        >
        >
        > That's what I thought initially, but what if I POST the url
        > '/webapp/servlet?param=v alue'
        >
        > There is no way (AFAICT) to tell whether 'param' was in the URL or a posted
        > parameter?
        >
        >
        >[/color]

        Sure you can - just do a request.getMeth od()... if its GET then you know
        it was on the command line, if its POST, then you know it was posted.
        You can also double check by parsing the URL and making sure that
        variable was not in it...


        Comment

        • Oliver Wong

          #5
          Re: ServletRequest. getParameter question


          "Questman" <questman@UBESU Xthemajorbbs.co m> wrote in message
          news:5UJ8g.9641 6$0w.52962@fe04 .usenetserver.c om...[color=blue]
          > Steve wrote:[color=green]
          >> On 8/5/06 01:23, in article J8w7g.34377$iB2 .33715@bignews4 .bellsouth.net,
          >> "Hal Rosser" <hmrosser@bells outh.net> wrote:
          >>
          >>[color=darkred]
          >>>"Steve" <root@127.0.0.1 > wrote in message
          >>>news:C0816F2 0.5911%root@127 .0.0.1...
          >>>
          >>>>Hi,
          >>>>
          >>>>I'm using ServletRequest. getParameter(), but how do I tell the
          >>>>differenc e a
          >>>>parameter in the query part of a URL and a posted parameter (e.g. an
          >>>>input
          >>>>field of a form where method="post").
          >>>>
          >>>
          >>>look at the doGet and doPost methods-
          >>>do either one and have it call the other one - passing the request and
          >>>response object[/color]
          >>
          >>
          >> That's what I thought initially, but what if I POST the url
          >> '/webapp/servlet?param=v alue'
          >>
          >> There is no way (AFAICT) to tell whether 'param' was in the URL or a
          >> posted
          >> parameter?
          >>
          >>
          >>[/color]
          >
          > Sure you can - just do a request.getMeth od()... if its GET then you know
          > it was on the command line, if its POST, then you know it was posted. You
          > can also double check by parsing the URL and making sure that variable was
          > not in it...[/color]

          That last check is dangerous: What if it were located in both?

          - Oliver

          Comment

          • Steve

            #6
            Re: ServletRequest. getParameter question

            On 11/5/06 17:46, in article 5UJ8g.96416$0w. 52962@fe04.usen etserver.com,
            "Questman" <questman@UBESU Xthemajorbbs.co m> wrote:
            [color=blue][color=green]
            >> That's what I thought initially, but what if I POST the url
            >> '/webapp/servlet?param=v alue'
            >>
            >> There is no way (AFAICT) to tell whether 'param' was in the URL or a posted
            >> parameter?
            >>[/color]
            >
            > Sure you can - just do a request.getMeth od()... if its GET then you know
            > it was on the command line, if its POST, then you know it was posted.[/color]

            The first bit I agree with - if the request method is GET, then obviously
            there can be no body to the request so all params must be from the URL.

            But, as I said what if I POST the url '/webapp/servlet?param=v alue'
            Take the following HTML form for example:


            <form method="post" action="/webapp/servlet?param1= value1">
            <input type="hidden" name="param2" value="value2"/>
            </form>

            So tell me - what methods are available to indicate param1 was from the URL
            and param2 was not.

            [color=blue]
            > You can also double check by parsing the URL and making sure that
            > variable was not in it...[/color]

            I'd rather not re-invent the wheel if I don't have to.


            --
            Regards,
            Steve

            "...which means he created the heaven and the earth... in the DARK! How good
            is that?"

            Comment

            Working...