| Author |
I have a problem with methods Get and Post
|
John Sutheran
Greenhorn
Joined: Oct 18, 2006
Posts: 3
|
|
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
Joined: Dec 11, 2004
Posts: 13410
|
|
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
|
Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56150
|
|
|
This was your second warning regarding your display name. Be aware that accounts with invalida display names are disabled.
|
[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
|
 |
John Sutheran
Greenhorn
Joined: Oct 18, 2006
Posts: 3
|
|
|
Sorry about that.
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56150
|
|
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.
|
 |
 |
|
|
subject: I have a problem with methods Get and Post
|
|
|