• Post Reply Bookmark Topic Watch Topic
  • New Topic

JSP not posting variables  RSS feed

 
Mike London
Ranch Hand
Posts: 1340
8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Rosco Duncan
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
meehul Chopra
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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???
 
Mike London
Ranch Hand
Posts: 1340
8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!