This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
The moose likes Servlets and the fly likes Getting values from id attribute in a servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » Servlets
Reply Bookmark "Getting values from id attribute in a servlet" Watch "Getting values from id attribute in a servlet" New topic
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
    
  13

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.
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Getting values from id attribute in a servlet
 
Similar Threads
using one bean across several forms
I can't use application and session to store data
How to submit a form with out a name in javascript
html:text how to set id attribute
Form element id