Enumeration of data

F

francan00

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("(e-mail address removed)");
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.
 
R

Roedy Green

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top