Forums Register Login

JSP not posting variables

+Pie Number of slices to send: Send
OK, this must really be simple, but I'm having trouble getting form variables to POST and show up in the same JSP after clicking Submit.

I have a form tag like this:

<form action="#" method="post" name="contactForm" id="contactForm">

// form text fields, etc.

</form>

Then, later in the JSP, I have something to test the POSTing:

String testt = request.getParameter("txtFname");
out.println("first name = " + testt);

However, the value prints: "first name=NULL"

This form is not positing, but some other code where I'm calling built-in request methods works OK.

The Submit button (defined inside the form tag) is defined like this:

<input type="submit" name="cmdSubmit" id="cmdSubmit" value="Submit" />

What is wrong here? I'm just trying to submit the form variables back to the same JSP so I can persist then with Hibernate.

Thanks to all for suggestions.

-- M
+Pie Number of slices to send: Send
Hi Mike,

Just trying to follow along with what you are doing. Am I right in understanding that you have a form on a jsp page that also includes some dumping of the request parameters of the same names as the form fields?

So you are doing the following:

1) you load the page, and are presented with the form followed by your debugging of the request parameters (showing nothing as expected)
2) you enter some content in the form and submit it
3) you are presented with the same page again, but you still arent seeing your request params populated

Is that correct?
+Pie Number of slices to send: Send
 

Mike London wrote:OK, this must really be simple, but I'm having trouble getting form variables to POST and show up in the same JSP after clicking Submit.

I have a form tag like this:

<form action="#" method="post" name="contactForm" id="contactForm">

// form text fields, etc.

</form>

Then, later in the JSP, I have something to test the POSTing:

String testt = request.getParameter("txtFname");
out.println("first name = " + testt);

However, the value prints: "first name=NULL"

This form is not positing, but some other code where I'm calling built-in request methods works OK.

The Submit button (defined inside the form tag) is defined like this:

<input type="submit" name="cmdSubmit" id="cmdSubmit" value="Submit" />

What is wrong here? I'm just trying to submit the form variables back to the same JSP so I can persist then with Hibernate.

Thanks to all for suggestions.

-- M


Hi Mike,

As far as I see your code ,,for the first time when you load it will print
firstname = NULL
and when you submit it,that is call the same page,you should get the output as
firstname= //whatever name entered previously.

If you could send us the entire code???
+Pie Number of slices to send: Send
For whatever reason, the JSP code "self-healed". The form's POST variables are working as expected now.

Not sure what was happening yesterday.

Thanks for the replies!

- Mike
To get a wish, you need a genie. To get a genie, you need a lamp. To get a lamp, you need a tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 1261 times.
Similar Threads
Simple form: inputText does not reset
Bean instantiation from JSP
Navigation problem in struts
using ajax and struts iterate tags
Internal servlet error?
More...

All times above are in ranch (not your local) time.
The current ranch time is
Apr 16, 2024 06:30:06.