Problem getting post vars
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 7 of 7

Thread: Problem getting post vars

  1. #1
    Join Date
    Mar 2010
    Posts
    5

    Post Problem getting post vars

    Hello, we have a JSP application running from eclipse. If we try to post a form to another JSP page, all pot variables returns null using request.getAttibyte o r request.getParameter. If we post the same form to the same page, the getParameter function works fine. Any ideas? Thanks

  2. #2
    Join Date
    Jul 2005
    Location
    Currently in Mexico City
    Posts
    568

    Re: Problem getting post vars

    How do you send the data to another JSP?

    I feel you forgot to mention a lot in your post. I could bet that either there's something in the middle between your JSPs or you simply get the stuff the wrong way.
    Code:
    String myParam = request.getParameter("myParam");
    1. If there's a servlet in the middle involved make sure you forward the request object.
    2. Do not use redirect or the data will be lost.
    3. Try to use GET method in the sending form to see the parameters in the url string and where they are being lost.
    4. getAttribute() method has nothing to do with form parameters since custom request attributes are set manually.

    To determine the nature of your problem your code is needed, better of both JSPs.
    Wanna install linux on a vacuum cleaner. Could anyone tell me which distro sucks better?

    I had a nightmare last night. I was dreaming that Iím 64-bit and my blanket is 32-bit and I couldnít cover myself with it, so Iíve spent the whole night freezing. And in the morning I find that my blanket just had fallen off the bed. =S (from: bash.org.ru)

    //always looking for job opportunities in AU/NZ/US/CA/Europe :P
    willCodeForFood(Arrays.asList("Java","PHP","C++","bash","Assembler","XML","XHTML","CSS","JS","PL/SQL"));

    USE [code] TAGS! Read this FAQ if you are new here. If this post was helpful, please rate it!

  3. #3
    Join Date
    Mar 2010
    Posts
    5

    Re: Problem getting post vars

    Hi,

    I have a simple page that contains a form: testJsp.jsp, it calls prueba.jsp which receives the post vars and print them. There's nothing in the middle.

    I'm attaching the two files.

    Thanks for your help!
    Attached Files Attached Files

  4. #4
    Join Date
    Mar 2010
    Posts
    5

    Re: Problem getting post vars

    I put those two jsp pages in another project, and they work fine. Could it be some compilation issue? Could it be a configuration issue?

  5. #5
    Join Date
    Jul 2005
    Location
    Currently in Mexico City
    Posts
    568

    Re: Problem getting post vars

    Didn't have time to see the problem right away... Have just tried to run it.

    The problem with your pages is that you do not set name attribute for form fields, as soon as you set it all works fine. In other words the request does contain your params but under object addresses, each param does not have a name assigned to it, so when you try to print em out using getParameter() obviously nothing happens.
    Last edited by Xeel; March 10th, 2010 at 04:09 PM.
    Wanna install linux on a vacuum cleaner. Could anyone tell me which distro sucks better?

    I had a nightmare last night. I was dreaming that Iím 64-bit and my blanket is 32-bit and I couldnít cover myself with it, so Iíve spent the whole night freezing. And in the morning I find that my blanket just had fallen off the bed. =S (from: bash.org.ru)

    //always looking for job opportunities in AU/NZ/US/CA/Europe :P
    willCodeForFood(Arrays.asList("Java","PHP","C++","bash","Assembler","XML","XHTML","CSS","JS","PL/SQL"));

    USE [code] TAGS! Read this FAQ if you are new here. If this post was helpful, please rate it!

  6. #6
    Join Date
    Mar 2010
    Posts
    5

    Re: Problem getting post vars

    Hi, I put the name in the fields that didn't have it, and I hace still the same error. If you see the first textarea did have the name: <textarea
    class="required" rows="4" cols="30" name="txtObjeto" id="txtObjeto"></textarea>

    Thanks!

  7. #7
    Join Date
    Jul 2005
    Location
    Currently in Mexico City
    Posts
    568

    Re: Problem getting post vars

    I ran the thing in Tomcat6 compiled with java 1.5 and 1.6 in Eclipse. Worked fine for me as soon as I set the inputs names.

    1. Have you tried to use GET method instead of POST? What do you see in the URL?
    2. Have you ever got to the second jsp? If yes, what is the printed output there?
    (please use exactly the same jsps you attached before, and if you change them, please reattach)
    Last edited by Xeel; March 11th, 2010 at 01:29 PM.
    Wanna install linux on a vacuum cleaner. Could anyone tell me which distro sucks better?

    I had a nightmare last night. I was dreaming that Iím 64-bit and my blanket is 32-bit and I couldnít cover myself with it, so Iíve spent the whole night freezing. And in the morning I find that my blanket just had fallen off the bed. =S (from: bash.org.ru)

    //always looking for job opportunities in AU/NZ/US/CA/Europe :P
    willCodeForFood(Arrays.asList("Java","PHP","C++","bash","Assembler","XML","XHTML","CSS","JS","PL/SQL"));

    USE [code] TAGS! Read this FAQ if you are new here. If this post was helpful, please rate it!

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center