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
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.
2 Attachment(s)
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!
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?
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.
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!
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)