• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Tricky

 
Raghu Kumar
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Is it possible to get the value in the servlet of a text field in HTML which doesn't have a name.
<input type="text" size="30" maxchars="30">
If i give the above in html a textfield is appearing. But if i want to retrieve the value entered using servlet how do i do that??

Thanks,
Raghu
 
Tony Alicea
Desperado
Sheriff
Posts: 3226
5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You give the <INPUT> a NAME="..." attribute and value. What's preventing you from doing it that way? Then use request.getParameter(...) to retrieve the String value of the INPUT element.
You can try the java.util.Enumeration getParameterNames() of the ServletRequest interface and see what is returned from a no-name INPUT... Probably nothing.
 
Raghu Kumar
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Actually the html file is generated by a xml file using some xsl. so the html is produced in such a way that the attribute NAME is not present. I am not aware of xml. o i can't tell any details about xml. so that's my requirement
Originally posted by Tony Alicea:
You give the <INPUT> a NAME="..." attribute and value. What's preventing you from doing it that way? Then use request.getParameter(...) to retrieve the String value of the INPUT element.
You can try the [b]java.util.Enumeration getParameterNames()
of the ServletRequest interface and see what is returned from a no-name INPUT... Probably nothing. [/B]

 
Frank Carver
Sheriff
Posts: 6920
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You won't be able to get the value directly, as it stands, but have you considered using sneaky JavaScript.
Instead of directly linking to your troublesome file, link to a frameset, with one frame very small (or not visible) but contiaining some JavaScript, and the other frame containing your "nameless" document. In the JavaScript, wait until the other frame is loaded, then go through all the elements in each of its forms and assign a name to any that don't have one.
With any luck, after this is done, submitting the troublesome form should also submit the newly named fields.
Is this any help?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic