Link to home
Start Free TrialLog in
Avatar of cbbl23
cbbl23

asked on

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

Avatar of cbbl23
cbbl23

ASKER

ooh,

Forget to say,

I use Jrun 2.3 and Windows NT/95.

Tia
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.
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
Avatar of cbbl23

ASKER

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



Avatar of cbbl23

ASKER

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
ASKER CERTIFIED SOLUTION
Avatar of Crawford
Crawford

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
>> As was mentioned before,

he-he

so why do wou ANSWER this question ?