I have a JSP Form with 15 inputs that is processed and emailed to
people.
I am using Enumeration to process and display the information. But I
need exact order of how the information is displayed and Enumerations
do not guarantee order so I have to do this:
Code: ( text )
Enumeration params = request.getParameterNames();
String text = "Form Information\n\n";
while (params.hasMoreElements()) {
//String name = (String)params.nextElement();
//String[] values = (String[])request.getParameter(name);
//String value = request.getParameter(name);
text += "First Name: " + request.getParameter("firstName");
text += "Last Name: " + request.getParameter("lastName");
text += "City: " + request.getParameter("city");
text += "County: " + request.getParameter("county");
text += "Project Info: " + request.getParameter("projInfo");
text += "Main Status: " + request.getParameter("mainStatus");
.....
.....
/*
if (values != null && values.length > 0) {
for (int i=0; i<values.length; i++) {
text += values + " ";
}
}
*/
}
//email the info
..........
EmailSender emailSender = new EmailSender();
emailSender.setFromEmail("info@company.com");
emailSender.setSubject(emailSubject);
emailSender.setText(text);
.........
Any better way?
Please advise because I dont have Struts and probably wont be allowed
to get it for a long time.
Roedy Green - 26 Oct 2007 07:39 GMT
>Any better way?
One technique is to squirt your enumeration into an ArrayList or array
then sort. I think though that you want a particular order that can't
easily be described. You could take your enumeration and put it in a
HashMap. Then look up each key in the order you want them.

Signature
Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com