Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Servlet --- req.getParameterNames()

Posted on 1999-07-22
7
Medium Priority
?
1,404 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
How to Create Failover DNS Record Sets in Route 53

Route 53 has the ability to easily configure DNS record sets specifically for failover scenarios. These failover record sets can be configured to failover to full-blown deployments in other regions or to a static HTML page that informs your customers of the issue.

 

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

The top UI technologies you need to be aware of

An important part of the job as a front-end developer is to stay up to date and in contact with new tools, trends and workflows. That’s why you cannot miss this upcoming webinar to explore the latest trends in UI technologies!

Question has a verified solution.

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

Introduction Java can be integrated with native programs using an interface called JNI(Java Native Interface). Native programs are programs which can directly run on the processor. JNI is simply a naming and calling convention so that the JVM (Java…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
Suggested Courses

671 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