This week's book giveaway is in the Mac OS forum.
We're giving away four copies of a choice of "Take Control of Upgrading to Yosemite" or "Take Control of Automating Your Mac" and have Joe Kissell on-line!
See this thread for details.
The moose likes Servlets and the fly likes Tricky Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Servlets
Bookmark "Tricky" Watch "Tricky" New topic
Author

Tricky

Raghu Kumar
Greenhorn

Joined: Jan 08, 2001
Posts: 9
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

Joined: Jan 30, 2000
Posts: 3222
    
    5
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.


Tony Alicea
Senior Java Web Application Developer, SCPJ2, SCWCD
Raghu Kumar
Greenhorn

Joined: Jan 08, 2001
Posts: 9
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

Joined: Jan 07, 1999
Posts: 6920
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?


Read about me at frankcarver.me ~ Raspberry Alpha Omega ~ Frank's Punchbarrel Blog
 
wood burning stoves
 
subject: Tricky