File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Servlets and the fly likes Getting values from id attribute in a servlet Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
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: 61766
    
  67

id values are not used for form submissions, that's what the name attribute is for.


[Asking smart questions] [Bear's FrontMan] [About Bear] [Books by 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: 19785
    
  20

Is this input field inside the form that you're submitting?


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
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://aspose.com/file-tools
 
subject: Getting values from id attribute in a servlet