?
Solved

Servlet --- req.getParameterNames()

Posted on 1999-07-22
7
Medium Priority
?
1,410 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
The new generation of project management tools

With monday.com’s project management tool, you can see what everyone on your team is working in a single glance. Its intuitive dashboards are customizable, so you can create systems that work for you.

 

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

[Webinar] Improve your customer journey

A positive customer journey is important in attracting and retaining business. To improve this experience, you can use Google Maps APIs to increase checkout conversions, boost user engagement, and optimize order fulfillment. Learn how in this webinar presented by Dito.

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…
A solution for Fortify Path Manipulation.
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.
Suggested Courses
Course of the Month3 days, 7 hours left to enroll

601 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