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().toStr ing();
// other processing
}
is random ( different from that in the HTML form).
Any idea? Solutions?
Thanks.
cbbl23
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().toStr
// other processing
}
is random ( different from that in the HTML form).
Any idea? Solutions?
Thanks.
cbbl23
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.
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.getParamete r("operato r");
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
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("
String m_Criteria=req.getParamete
String m_Param=req.getParameter("
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
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
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
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
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
>> As was mentioned before,
he-he
so why do wou ANSWER this question ?
he-he
so why do wou ANSWER this question ?
ASKER
Forget to say,
I use Jrun 2.3 and Windows NT/95.
Tia