Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Servlet --- req.getParameterNames()

Posted on 1999-07-22
7
Medium Priority
?
1,406 Views
Last Modified: 2013-11-24
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

0
Comment
Question by:cbbl23
7 Comments
 

Author Comment

by:cbbl23
ID: 1246797
ooh,

Forget to say,

I use Jrun 2.3 and Windows NT/95.

Tia
0
 
LVL 16

Expert Comment

by:heyhey_
ID: 1246798
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
 

Expert Comment

by:pratipgupta
ID: 1246799
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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

Author Comment

by:cbbl23
ID: 1246800
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
 

Author Comment

by:cbbl23
ID: 1246801
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
 
LVL 1

Accepted Solution

by:
Crawford earned 200 total points
ID: 1246802
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
 
LVL 16

Expert Comment

by:heyhey_
ID: 1246803
>> As was mentioned before,

he-he

so why do wou ANSWER this question ?
0

Featured Post

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
Suggested Courses

824 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question