• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • paul wheaton
  • Jeanne Boyarsky
  • Ron McLeod
Sheriffs:
  • Paul Clapham
  • Liutauras Vilda
  • Devaka Cooray
Saloon Keepers:
  • Tim Holloway
  • Roland Mueller
Bartenders:

urgent please

 
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Rancher
Posts: 13459
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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...
 
Sheriff
Posts: 4313
Android IntelliJ IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have the same problem of Jumbled output from getParameterNames().Anybody know the solution?
Please help.
 
Sheriff
Posts: 67753
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Please continue any discussion here.
thanks,
bear
[ September 12, 2003: Message edited by: Bear Bibeault ]
 
yeah, but ... what would PIE do? Especially concerning this tiny ad:
Smokeless wood heat with a rocket mass heater
https://woodheat.net
reply
    Bookmark Topic Watch Topic
  • New Topic