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 ?
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Mick BarryJava DeveloperCommented:
you should be able to
are the text fileds inside the form, and are you using the correct name

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
changcy77Author Commented:
I have checked all those and could not find anything missing.
changcy77Author Commented:
The only other thing is I use a javascript to validate some fields before submit sent out request.

<form name=..  action=...onSubmit=validate()>
Learn SQL Server Core 2016

This course will introduce you to SQL Server Core 2016, as well as teach you about SSMS, data tools, installation, server configuration, using Management Studio, and writing and executing queries.

is text field  inside <form..> </form>?
Manikandan ThiagarajanSenior consultantCommented:
give correct textfieldname or variable name in request.getParameter("text1");
The form name and event listeners (onChange, onSubmit, etc) are not relevant to this discussion since they are only used in javascript (client-side) whereas the values that are submitted are processed in the servlet (server-side).

The following form would work:

<form action="testServlet" method="get">

<input type='text' name="name" size='20' value='This is my name'>

<input type="submit"><input type="reset">


In the servlet itself you will have a method called doGet(HttpServletRequest request, HttpServletResponse response).

This is what is called by a form with method "get". To read the form field values, use request.getParameter(parameterName) so in the above example
String name = request.getParameter("name") would result in a new string variable called name which would  have a value of "This is my name"

String name = request.getParemter("name") ;
if (name == "This is my name") {
   name = "" ;
} else {
   // do something
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 ;-)


        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

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(..)
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.