Bizarre getParameter in doPost method of servlet.

Discussion in 'Java' started by Fred, Aug 20, 2003.

  1. Fred

    Fred Guest

    Strange problem. I have an html form that sends a POST request to a
    servlet, but all the "request.getParameter()" requests are returning
    null.

    Here's a snippet:

    public void doGet|Post(HttpServletRequest request,
    HttpServletResponse response) throws ServletException, IOException
    {
    String baseDir = request.getParameter("baseDir");
    String subDir = request.getParameter("subDir");
    String description = request.getParameter("description");

    if(debug)
    {
    log("baseDir = " + baseDir);
    log("subDir = " + subDir);
    log("description = " + description);
    }
    }

    So the problem is that, even givin the exact same code for both, the
    doGet method will display (in the log file) the values requested. In
    the doPost method, it's always null values.

    So what am I missing? I want to make it clear that doGet works (and I
    can even see the values in the browser location bar).
    Fred, Aug 20, 2003
    #1
    1. Advertising

  2. Fred

    Alex Koltun Guest

    Hi,
    I suspect that the problem is in html code calling this servlet,
    can you send the html you use?
    anyway check the enctype attribute of the <form> tag...
    is it: enctype="multipart/form-data" ?

    Regards,
    Alex Koltun

    (Fred) wrote in message news:<>...
    > Strange problem. I have an html form that sends a POST request to a
    > servlet, but all the "request.getParameter()" requests are returning
    > null.
    >
    > Here's a snippet:
    >
    > public void doGet|Post(HttpServletRequest request,
    > HttpServletResponse response) throws ServletException, IOException
    > {
    > String baseDir = request.getParameter("baseDir");
    > String subDir = request.getParameter("subDir");
    > String description = request.getParameter("description");
    >
    > if(debug)
    > {
    > log("baseDir = " + baseDir);
    > log("subDir = " + subDir);
    > log("description = " + description);
    > }
    > }
    >
    > So the problem is that, even givin the exact same code for both, the
    > doGet method will display (in the log file) the values requested. In
    > the doPost method, it's always null values.
    >
    > So what am I missing? I want to make it clear that doGet works (and I
    > can even see the values in the browser location bar).
    Alex Koltun, Aug 21, 2003
    #2
    1. Advertising

  3. Fred

    Fred Guest

    (Alex Koltun) wrote in message news:<>...
    > Hi,
    > I suspect that the problem is in html code calling this servlet,
    > can you send the html you use?
    > anyway check the enctype attribute of the <form> tag...
    > is it: enctype="multipart/form-data" ?
    >
    > Regards,
    > Alex Koltun


    Yes, that's right - among other things, I want to upload a file, but I
    also want the user to specify a few options about the file. So if I
    can't use the "normal" techniques when using multipart/form-data, I
    suppose I have to use the same techniques that retrieve the file to
    retrieve the form data?
    Fred, Aug 22, 2003
    #3
    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. bigbinc

    Fill doGet, doPost in servlet

    bigbinc, Feb 26, 2004, in forum: Java
    Replies:
    1
    Views:
    5,607
    Oscar kind
    Feb 26, 2004
  2. Steve
    Replies:
    1
    Views:
    535
    Hywel
    Sep 24, 2004
  3. =?utf-8?B?6L65IOaxnw==?=

    [Servlet] how to send a stream to servlet doPost

    =?utf-8?B?6L65IOaxnw==?=, Sep 14, 2007, in forum: Java
    Replies:
    3
    Views:
    642
    GArlington
    Sep 14, 2007
  4. Replies:
    2
    Views:
    408
    Chris ( Val )
    Nov 13, 2007
  5. paramsethi
    Replies:
    6
    Views:
    6,557
    paramsethi
    Mar 24, 2010
Loading...

Share This Page