changcy77
asked on
why form submit to a servlet could not retrive the parameter values?
I have a form which has tag like this:
<form name="frm1" action="servlet">
I found I could only retrieve request.getParameter() in the servlet to retrieve hidden type parameter values, not the form object parameter value. so, if I want to get the value from a text field, the request.getParameter() return null.
Why? How to fix ?
<form name="frm1" action="servlet">
I found I could only retrieve request.getParameter() in the servlet to retrieve hidden type parameter values, not the form object parameter value. so, if I want to get the value from a text field, the request.getParameter() return null.
Why? How to fix ?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
The only other thing is I use a javascript to validate some fields before submit sent out request.
<form name=.. action=...onSubmit=validat e()>
<form name=.. action=...onSubmit=validat
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
One thing to note, if the control is disabled then it doesn't post anything with the form...
Not sure if this applies here...
Just thought I'd chime in ;-)
Tim
Not sure if this applies here...
Just thought I'd chime in ;-)
Tim
changcy77,
Can you post or look at your self about your html code in your browser? You have to make sure that there is a text field which also needs to be inside
<form>
here!
</form>
Acton
Can you post or look at your self about your html code in your browser? You have to make sure that there is a text field which also needs to be inside
<form>
here!
</form>
Acton
I found it is actually a stupid mistake that I have one text field and one select filed that both have the same names since they represent the same entries(one for new entry, one for choosing from existing entries). so, since only one of them got entered, so the empty one passed the null value to request.
On the other hand, what would be a good solution for this problem? I could either name them differently or there is other better way of doing this? thanks.
On the other hand, what would be a good solution for this problem? I could either name them differently or there is other better way of doing this? thanks.
if they represent different things, you have to name them differently. otherwise, you could try request.getParamters(..)
ASKER