Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / October 2007

Tip: Looking for answers? Try searching our database.

Enumeration of data

Thread view: 
francan00@yahoo.com - 25 Oct 2007 21:27 GMT
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



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.