• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
  • Piet Souris
  • Himai Minh


Ranch Hand
Posts: 174
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have ShowMessage.html and ShowMessageServlet.java . All work fine.
<TITLE>XYZ Corporation, Service IT </title>
<BODY bgcolor="#FCF054">
<H1>Requête </H1>

<FORM ACTION="/projet/servlet/ShowMessageServlet" METHOD="POST">
<TD >Firstname :</TD>
<TD><INPUT TYPE="Text" NAME="firstName" SIZE="20"></TD>
<TD><INPUT TYPE="Text" NAME="lastName" SIZE="20"></TD>
<TD><INPUT TYPE="Text" NAME="email" SIZE="20"></TD>
<TD>phone :</TD>
<TD><INPUT TYPE="Text" NAME="phone" SIZE="20"></TD>
<INPUT TYPE="Submit" VALUE="Submit Request">

My Servlet :
import javax.servlet.*;
import javax.servlet.http.*;
import java.util.*;
// Importation des autres paquetages Java
import java.io.*;
public class ShowMessageServlet extends HttpServlet {

protected void doPost(HttpServletRequest req, HttpServletResponse res)
throws ServletException, IOException {

String NoValue="NoValue entered";

PrintWriter out = res.getWriter();
out.println(" Confirmation de requête ");
out.println("<P><U><H3><B>Here are your information :</B></H3></U></P>");
Enumeration enum = req.getParameterNames();
while(enum.hasMoreElements()) {
String paramName=(String)enum.nextElement();
String paramValue =req.getParameter(paramName);
if(paramValue.length()==0) {



My response is :
phone: NoValue entered
email: NoValue entered
lastName: OKUCU
firstName: Engin
But in my ShowMessage.html 'firstName' is the first line and in my response i get it as the last line.
How can I resolve it ?thanks.
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The problem is that using getParameterNames() to return an enumeration of the parameter names does not specify any order appear within the enumeration. If you want to retrieve and display your parameters in any order you have to use getParameter(String parameterName) to retrieve them one at a time.
Engin Okucu
Ranch Hand
Posts: 174
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Drew,
I thank you for your reply. But say, a developer has any knowledge of the parameters in the html page ok? And he wants to retrieve all parameters in a specified order, one at time by order. How has he to do then ? is it possible to do it?
You don't know me, but I've been looking all over the world for. Thanks to the help from this tiny ad:
free, earth-friendly heat - a kickstarter for putting coin in your pocket while saving the earth
    Bookmark Topic Watch Topic
  • New Topic