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

x
?
Solved

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

Posted on 2006-03-29
11
Medium Priority
?
678 Views
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 ?
0
Comment
Question by:changcy77
10 Comments
 
LVL 92

Accepted Solution

by:
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
0
 

Author Comment

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

Author Comment

by:changcy77
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()>
0
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

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

Assisted Solution

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

Assisted Solution

by:itamar82
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">

</form>

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
}
0
 
LVL 35

Expert Comment

by:TimYates
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 ;-)

Tim
0
 
LVL 19

Expert Comment

by:actonwang
ID: 16333455
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
0
 

Expert Comment

by:sarahchi
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.
0
 
LVL 19

Expert Comment

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

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