I am not a JSP guru but maybe this helps.
Depending on the container you have, you can get different results on the
generated class file. Try to locate the generated class file on your
directory structure and follow the code to see if you find what could be
wrong.



-----Original Message-----
From: Awad Katherin [mailto:[EMAIL PROTECTED]]
Sent: Thursday, July 13, 2000 7:59 PM
To: [EMAIL PROTECTED]
Subject: Calling an Enumeration in the java file from the JSP page


     Hi,

     I'm trying to call a function in my java file from my JSP page in
     order to populate a drop-down box. The java function returns an
     enumeration which I go through to select the appropriate parts to
     display.

     However, it is not populating the drop down at all - it doesn't even
     get in the while loop - so it must be falling over on
     e.hasMoreElements(). I tried writing a main function in the java file
     with exactly the same code to test it and it works perfectly.

     What am I doing wrong in the JSP page? Here are snippets of the code:

     JSP Page
     --------

     <td><b>Label:</b></td><td><select name="dropdown" width="45">
           <option value=" " selected>Select an Option
        <%
           Enumeration e = DBClass.getPopulate();
           while (e.hasMoreElements()) {
             Someclass myclass = (Someclass) e.nextElement();
       %>
     <option value="<%=myclass.getID()%>"><%=myclass.getSummary()%>
       <%  }
       %>
     </select></td>


     Java Page - function that is called within class "DBClass"
     ----------------------------------------------------------

     public static Enumeration getPopulate()
             {

             SList holder = new SList();
             ResultSet rs = null;

     try {

                 // connect to database in here

            try {

                // RS set here using query  execution

               while (rs.next()) {

                   holder.add(new Someclass(rs.getString(1),
     rs.getString(2), rs.getString(3)));
               }

            } catch (SQLException se) {
                  se.printStackTrace();
            }

                // close connection here

       } catch (Exception e) {
           e.printStackTrace();
       }

       return holder.elements();
     }


     Thanks for your time.

     Katherin.


     *************************************


This message contains confidential information and is intended only
for the individual named.  If you are not the named addressee you
should not disseminate, distribute or copy this e-mail.  Please
notify the sender immediately by e-mail if you have received this
e-mail by mistake and delete this e-mail from your system.

E-mail transmission cannot be guaranteed to be secure or error-free
as information could be intercepted, corrupted, lost, destroyed,
arrive late or incomplete, or contain viruses.  The sender therefore
does not accept liability for any errors or omissions in the contents
of this message which arise as a result of e-mail transmission.  If
verification is required please request a hard-copy version.  This
message is provided for informational purposes and should not be
construed as a solicitation or offer to buy or sell any securities or
related financial instruments.

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
JSP-INTEREST".
Some relevant FAQs on JSP/Servlets can be found at:

 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.html
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets

===========================================================================
To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff JSP-INTEREST".
Some relevant FAQs on JSP/Servlets can be found at:

 http://java.sun.com/products/jsp/faq.html
 http://www.esperanto.org.nz/jsp/jspfaq.html
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=JSP
 http://www.jguru.com/jguru/faq/faqpage.jsp?name=Servlets

Reply via email to