Link to home
Start Free TrialLog in
Avatar of changcy77
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 ?
ASKER CERTIFIED SOLUTION
Avatar of Mick Barry
Mick Barry
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of changcy77
changcy77

ASKER

I have checked all those and could not find anything missing.
The only other thing is I use a javascript to validate some fields before submit sent out request.

<form name=..  action=...onSubmit=validate()>
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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
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
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.
if they represent different things, you have to name them differently. otherwise,  you could try request.getParamters(..)