Enumeration issue

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • chicago1985
    New Member
    • Oct 2007
    • 9

    #1

    Enumeration issue

    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:
    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 to list the information?
    Please advise because I dont have Struts and probably wont be allowed to get it for a long time.
  • JosAH
    Recognized Expert MVP
    • Mar 2007
    • 11453

    #2
    You should've created a simple class for that first name, last name, city etc.
    Don't stick them in as attributes which have nothing to do with each other.

    kind regards,

    Jos

    Comment

    • chicago1985
      New Member
      • Oct 2007
      • 9

      #3
      Originally posted by JosAH
      You should've created a simple class for that first name, last name, city etc.
      Don't stick them in as attributes which have nothing to do with each other.

      kind regards,

      Jos
      Thanks,

      You mean JavaBean class with getter and setter methods???

      Comment

      • JosAH
        Recognized Expert MVP
        • Mar 2007
        • 11453

        #4
        Originally posted by chicago1985
        Thanks,

        You mean JavaBean class with getter and setter methods???
        Yup, those beanies alright. Your JSP pages like them and it takes off the burden
        of remembering 'an order' of certain properties.

        kind regards,

        Jos

        Comment

        • chicago1985
          New Member
          • Oct 2007
          • 9

          #5
          Thanks for your quick responses.

          I will try it with JSP and JavaBeans as you suggested.

          Comment

          Working...