• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

I have a problem with methods Get and Post

 
John Sutheran
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

I have a problem with the Get and Post methods in my JSP. My code looks somthing like this.

JavaScript
function submitForm(queryId) {
document.formReview.action = document.formReview.action+"?action="+ queryId;
document.formReview.submit();
}

<form name="formReview" id="formReview" method="post" action="myServlet">
------Here I have a list of records. When the user clicks on the ID of one of the records I am calling a JavaScript function submitForm which submits the request with ID.
</form>

In the servlet I am able to get the ID using request.getParameter("action") if the method is POST. But the problem is with the method GET. If I am using GET then I am getting the ID as null. What could be the reason for this?

Thank you
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Johnny,
Welcome to JavaRanch!

We're pleased to have you here with us in the JSP forum, but there
are a few rules that need to be followed, and one is that proper names are
required. Please take a look at the
JavaRanch Naming Policy and
adjust your display name to match it.

In particular, your display name must be a first and a last name separated by a space character, and must not be obviously fictitious.

You can change it here
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64620
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This was your second warning regarding your display name. Be aware that accounts with invalida display names are disabled.
 
John Sutheran
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sorry about that.
 
Bear Bibeault
Author and ninkuma
Marshal
Pie
Posts: 64620
86
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't know whether this is what is screwing you up or not, but...

document.formReview.action = document.formReview.action+"?action="+ queryId;


it's not the best of idea to put query parameters on a form action. Rather, create a hidden input and set the value into the input before submitting the form.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic