[Last Call] Learn how to a build a cloud-first strategyRegister Now


why form submit to a servlet could not retrive the parameter values?

Posted on 2006-03-29
Medium Priority
Last Modified: 2008-03-03
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 ?
Question by:changcy77
LVL 92

Accepted Solution

objects earned 120 total points
ID: 16327245
you should be able to
are the text fileds inside the form, and are you using the correct name

Author Comment

ID: 16327741
I have checked all those and could not find anything missing.

Author Comment

ID: 16327756
The only other thing is I use a javascript to validate some fields before submit sent out request.

<form name=..  action=...onSubmit=validate()>
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

LVL 19

Assisted Solution

actonwang earned 100 total points
ID: 16328147
is text field  inside <form..> </form>?

Assisted Solution

by:Manikandan Thiagarajan
Manikandan Thiagarajan earned 100 total points
ID: 16329576
give correct textfieldname or variable name in request.getParameter("text1");

Assisted Solution

itamar82 earned 80 total points
ID: 16332391
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
LVL 35

Expert Comment

ID: 16332440
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 ;-)

LVL 19

Expert Comment

ID: 16333455

        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


Expert Comment

ID: 16336362
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.
LVL 19

Expert Comment

ID: 16336521
if they represent different things, you have to name them differently. otherwise,  you could try request.getParamters(..)

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Microsoft Office Picture Manager was included in Office 2003, 2007, and 2010, but not in Office 2013. Users had hopes that it would be in Office 2016/Office 365, but it is not. Fortunately, the same zero-cost technique that works to install it with …
Moore’s Law has proven itself time and time again since it was first introduced. So what’s next? Will Moore’s law continue to remain relevant, or will new technology take over and bring us the next big advancement in computing?
In a question here at Experts Exchange (https://www.experts-exchange.com/questions/29062564/Adobe-acrobat-reader-DC.html), a member asked how to create a signature in Adobe Acrobat Reader DC (the free Reader product, not the paid, full Acrobat produ…
Whether it be Exchange Server Crash Issues, Dirty Shutdown Errors or Failed to mount error, Stellar Phoenix Mailbox Exchange Recovery has always got your back. With the help of its easy to understand user interface and 3 simple steps recovery proced…
Suggested Courses
Course of the Month17 days, 23 hours left to enroll

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question