• 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
  • Ron McLeod
  • Paul Clapham
  • Tim Cooke
  • Devaka Cooray
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Rob Spoor
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Piet Souris
  • Mikalai Zaikin
Bartenders:
  • Carey Brown
  • Roland Mueller

Enumeration Object problem

 
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I am getting all parameters of textFields of jsp page.I getting these parameters with Enumeration object that return all parameter names in different order.For example i create textfields in this order id,name,rollNo,Marks.It returns in different order like as rollNo,Marks,id,name.How can I get values in order as i created in jsp page.
 
Ranch Hand
Posts: 182
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

faisal hameed wrote:How can I get values in order as i created in jsp page.



I guess you can not. Because the parameters are probably put into a map and map has to deal with collision etc. and has its own order of items. Anyways why you should need that? I can not see any obligation to do what you want.

Regards,

Fatih.
 
Ranch Hand
Posts: 3389
Mac MySQL Database Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Exactly as Fatih said that is what happening internally. All the request, session, application scope values are indeed backed up by a HashMap. So you don't have a control on the order of values.
 
Ranch Hand
Posts: 276
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Fatih Keles wrote:
I guess you can not.



He could parse the query string / post data...
 
faisal hameed
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i need it for my Home Assignment.
from first JSP index i have to get my values from text fields when buttn in pushed. But enumeration onject changes the order of all the value which are gotton from txt fields. How can I get the order in which the Values are stored into the enumeration object.
Please Help.
 
Lorand Komaromi
Ranch Hand
Posts: 276
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

faisal hameed wrote:
from first JSP index i have to get my values from text fields when buttn in pushed.
Please Help.



You need the value of the first text field when the form is submitted..?
 
Raghavan Muthu
Ranch Hand
Posts: 3389
Mac MySQL Database Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

faisal hameed wrote:i need it for my Home Assignment.
from first JSP index i have to get my values from text fields when buttn in pushed. But enumeration onject changes the order of all the value which are gotton from txt fields. How can I get the order in which the Values are stored into the enumeration object.
Please Help.



You can accomplish the same by using the name of each property/parameter. Cant you do that? You can retrieve each parameter by its name and store the value. I don't think you can get an ordered values from the enumeration object until it was backed by it. Even if it so it would be based on the natural order and NOT your order of insertion.

As I said earlier, it is NOT in our hands but the container.
 
Raghavan Muthu
Ranch Hand
Posts: 3389
Mac MySQL Database Tomcat Server
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I do NOT know is there a default way. Still if you want to have it done, you can do it manually by prefixing the number (as an order for each component say text field as per your example). Then in the enumeration after retrieving it you can manually get the substring and arrange it in ascending order. -- Overall, it would be a painful job.

Give it a shot if your requirement badly insists you to do so!
 
faisal hameed
Ranch Hand
Posts: 48
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
i can get manually all values in order.but if i dont know about no of textfields in jsp page then there is problem.
 
Fatih Keles
Ranch Hand
Posts: 182
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

faisal hameed wrote:i can get manually all values in order.but if i dont know about no of textfields in jsp page then there is problem.



I believe you have to consider your requirements. How can a servlet/jsp can handle input parameters that are not known until form request processing?

One answer will be : if adding text inputs with javascript is the issue and you have to exactly process the text inputs as in the order that they exist on your jsp page then make text inputs have generic names like "text1", "text2" and so on and pass the number of text inputs to form request handler. But all these are turn around and will bother you some time later when you have to add new functionality to your pages. Or again have them names that reflect the order of the items on your page and consider sorting parameter names. But first one will be an easy and a novice solution.

Regards,

Fatih.
 
If you two don't stop this rough-housing somebody is going to end up crying. Sit down and read this tiny ad:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic