aspose file tools*
The moose likes Servlets and the fly likes Getting values of dynamically created text fields Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Getting values of dynamically created text fields" Watch "Getting values of dynamically created text fields" New topic
Author

Getting values of dynamically created text fields

Vijaishanker bala
Ranch Hand

Joined: Sep 08, 2005
Posts: 82
Hi,
In a web application of mine, I am having a form and in that form, textfields(<input type "text"> are created dynamically based on parameters passed from another program. The user fills in values. The common thing among these textfields are they have their names starting with "tfDyn". After the user fills in values, and on submission of the form a servlet is called that is supposed to do some processing based upon the submitted form. My question is,in the servlet, is it possible to get the names and values of the textfields, those that were generated at runtime... if yes, how..or else is there any other way to achieve the same..

Thanks

Vijai


When you say "I wrote a program that crashed Windows," people just stare at you blankly and say "Hey, I got those with the system, for free." <br />Linus Torvalds
aslam parveez
Ranch Hand

Joined: Apr 25, 2006
Posts: 47


Perhaps this is what you are looking for where paramName should be the the name of your text field in the HTML form. Remember to give the same name to all the textFields what ever the number you have dynamically created.
Vijaishanker bala
Ranch Hand

Joined: Sep 08, 2005
Posts: 82
Thanks Aslam
But if I give all the text fields the same name, I wont be able to sort out which value belongs to which text field, since they are unique values which need to processed uniquely,depending on the name of the textfield. I am trying my luck right now, with
request.getParameterMap() on this one.

Vijai
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12825
    
    5
If you are generating the parameter names, why not remember them in the session as they are being written to the form?
aslam parveez
Ranch Hand

Joined: Apr 25, 2006
Posts: 47


Probably helps...
Vijaishanker bala
Ranch Hand

Joined: Sep 08, 2005
Posts: 82
Thanks Aslam,

the code snippet you provided worked like a charm. Have used it in my application.

Thanks

Vijai
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Getting values of dynamically created text fields