Servlet --- req.getParameterNames()

Hi,

I used req.getParameterNames() to get all the names of feilds submitted via a form.

The problem is that the order of fields when I use

Enumberation fields = req.getParameterNames();
while ( fields.hasMoreElements())
{
String fieldName = fields.nextElement().toString();
// other processing
}

is random ( different from that in the HTML form).

Any idea? Solutions?

Thanks.

cbbl23

cbbl23Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

cbbl23Author Commented:
ooh,

Forget to say,

I use Jrun 2.3 and Windows NT/95.

Tia
0
heyhey_Commented:
the parameters are (probably) stored inside a Hashtable, so they are not ordered.

why do you need this functionality

the only 'sort' solution is to get all the names and sort them yourself.
0
pratipguptaCommented:
in case of using getParameternames() u can getParameter() func. in which u can specify the name of Field on the
form, of which u want to get the value.so there is no problem of order.
i giving u one sample

String m_Field=req.getParameter("FName");
String m_Criteria=req.getParameter("operator");
String m_Param=req.getParameter("Param");
 
here Fname,operator,Param are the  names of the field on
  the   form  of which i want to get the value
field on the html form is defined like this
<input type="text" name="FName" >
<input type="text" name="operator" >
<input type="text" name="Param" >

if u satisfied then reply me soon
0
Introducing Cloud Class® training courses

Tech changes fast. You can learn faster. That’s why we’re bringing professional training courses to Experts Exchange. With a subscription, you can access all the Cloud Class® courses to expand your education, prep for certifications, and get top-notch instructions.

cbbl23Author Commented:
Hi,

Thanks for responding.

The reason why I need to have this functionality is that the servlet must be general
and can be used in any HTML forms. This means that how many fields and their
names are unknown before hand.

BTW, I found a solution by writing a parser to process the InputStream myself.
It workes with forms which do not have any field of type=file.

cbbl23



0
cbbl23Author Commented:
Hi,

     Thanks for responding.

     The reason why I need to have this functionality is that the servlet must be general
     and can be used in any HTML forms. This means that how many fields and their
     names are unknown before hand.

     BTW, I found a solution by writing a parser to process the InputStream myself.
     It workes with forms which do not have any field of type=file.

     cbbl23
0
CrawfordCommented:
As was mentioned before, the parameters are probably stored in a Hashtable
or other mapping and will not be displayed in order. More importantly -- there
is no guarantee that the parameters will come from the browser in the same order.


0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
heyhey_Commented:
>> As was mentioned before,

he-he

so why do wou ANSWER this question ?
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java EE

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.