| Author |
Getting values from id attribute in a servlet
|
sovan chatt
Ranch Hand
Joined: Aug 09, 2010
Posts: 43
|
|
In a html form I have wrritten this,<input type="text" id="demo">,Now if I use the method request.getAttribute("id") in the servlet I get a null value.Why is that?
How can I use "id" attribute declared in a html form ,in a servlet.Or is it the case that only getparameter will work with name attribute
|
 |
Bear Bibeault
Author and ninkuma
Marshal
Joined: Jan 10, 2002
Posts: 56221
|
|
|
id values are not used for form submissions, that's what the name attribute is for.
|
[Smart Questions] [JSP FAQ] [Books by Bear] [Bear's FrontMan] [About Bear]
|
 |
Seetharaman Venkatasamy
Ranch Hand
Joined: Jan 28, 2008
Posts: 5575
|
|
|
and you have to use request.getParameter("name"), not request.getAttribute("id") .
|
 |
sovan chatt
Ranch Hand
Joined: Aug 09, 2010
Posts: 43
|
|
|
i have used the following in <input name="demo1" id="demo1" type="text">,now request.getParameter("demo1") fetches null!!
|
 |
Rob Spoor
Sheriff
Joined: Oct 27, 2005
Posts: 19216
|
|
|
Is this input field inside the form that you're submitting?
|
SCJP 1.4 - SCJP 6 - SCWCD 5
How To Ask Questions How To Answer Questions
|
 |
sovan chatt
Ranch Hand
Joined: Aug 09, 2010
Posts: 43
|
|
Yes,I used the input field in side the form...Here is the entire form..I used id attributes inside test and Dept. Date field.
|
 |
 |
|
|
subject: Getting values from id attribute in a servlet
|
|
|