• Post Reply Bookmark Topic Watch Topic
  • New Topic

urgent please  RSS feed

 
vinay bedidha
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i want to capture all the html form field 's names in the jsp.
iam having 10 textfields in the html page.iam doing it with the following code.
Enumeration e=request.getParameterName()
while(e.hasMoreElements())
{
String s=(String)e.nextElement();
out.println(s);
}
i getting all the field names from the html form.But my problem is that the values are not displaying in sorting order.i.e.,first text field name is printing in 8 position and 2 text field name in 3 position.i.e., the values are printed randomaly.i want 1 field name to be printed first in browser.please help me.iam in very urgent.thanks in advance.
iam pasting the html and jsp code...
<input type=text name = txt_User_Id_V>
<input type=text name = txt_User_Pwd_V>
<input type=text name = txt_User_Add_Pobox_V>and so on...
jsp code..
Enumeration e;
e=request.getParameterNames();
while(e.hasMoreElements())
{
String s=(String)e.nextElement();
out.println(s);
}

output..
txt_User_Add_Street_V
txt_User_Pwd_V
txt_User_Add_Place_V
txt_User_Add_Email_V
txt_User_Add_Pobox_V
txt_User_Add_Contact_V
txt_User_Add_Zip_V
txt_User_Add_City_V
txt_User_Add_Phone_V
txt_User_Id_V
txt_User_Name_V
 
David O'Meara
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think there may be other solutions, but I tend to save the list of form names in the order I want as a separate hidden field, then iterate over this list.
Dave.
 
Rehan Malik
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you already know the form field parameter names, then why not just retrieve just those parameters? And the way I'm seeing it, I don't think that you would ideally want to store the request parameter values into the same string over and over unless all you plan to do is print the values out.
i.e
String username = request.getParameter("username");
String password = request.getParameter("password");
and so on...
 
Jessica Sant
Sheriff
Posts: 4313
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by vinay bedidha:
i getting all the field names from the html form.But my problem is that the values are not displaying in sorting order.i.e.,first text field name is printing in 8 position and 2 text field name in 3 position.i.e., the values are printed randomaly.i want 1 field name to be printed first in browser.please help me.iam in very urgent.thanks in advance.
iam pasting the html and jsp code...

The HttpServletRequest API doesn't specify the order the names appear within the Enumeration for .getParameterNames() -- so you can't count on getting them back in the order they were originally listed in your HTML page -- you'll need to write some code around the enumeration to sort the list or to identify which parameter you're getting first in the enumeration.
------------------
- Jessica Bradley
HP Bluestone
 
chitradurga challekere
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have the same problem of Jumbled output from getParameterNames().Anybody know the solution?
Please help.
 
Bear Bibeault
Author and ninkuma
Marshal
Posts: 65833
134
IntelliJ IDE Java jQuery Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please continue any discussion here.
thanks,
bear
[ September 12, 2003: Message edited by: Bear Bibeault ]
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!