Ajay,
You need to change this line:
     public ArrayList testList;
to
     public ArrayList testList = new ArrayList();

Your message is a little confusing, I see a bean class but no tag class.

-Richard


At 05:20 PM 8/28/01 -0700, you wrote:
>I am a newbie and trying to find out how to have a custom tag create an
>arraylist to send to my jsp page. Currently I have a tag class that will
>access my database and create a resultset. I then try to insert that
>resultset into an ArrayList, and return the arrayList. Here is my code in
>my bean:
>
>import java.beans.*;
>import java.sql.*;
>import java.util.*;
>
>public class infoBean extends Object implements java.io.Serializable {
>
>     private String location_data;
>     private String title_data;
>     public ArrayList testList;
>
>     /** Creates new infoBean */
>     public infoBean() {
>         location_data = "";
>         title_data = "test2";
>
>     }
>
>     public String getLocation() {
>         return location_data;
>     }
>
>     public void setLocation (String value) {
>         location_data = value;
>     }
>
>     public String getTitle() {
>         return title_data;
>     }
>
>     public void setTitle (String value) {
>         title_data = value;
>     }
>
>     public ArrayList getLocationList() {
>
>             try{
>
>                 Class.forName("oracle.jdbc.driver.OracleDriver");
>
>                 Connection myConn = DriverManager.getConnection
> ("jdbc:oracle:thin:@enaoracle1:1521:one", "****", "*****");
>
>                 Statement myStmt = myConn.createStatement();
>
>         ResultSet myRs = myStmt.executeQuery("Select location from
> location");
>
>         while (myRs.next()) {
>          testList.add(myRs.getString("location"));
>         }
>
>         myRs.close();
>         myStmt.close();
>
>                 } catch (SQLException exc) {
>            exc.printStackTrace();
>
>         } catch (ClassNotFoundException exc) {
>            exc.printStackTrace();
>                 }
>                 return testList;
>     }
>
>
>}
>
>The code in my JSP page is:
><jsp:useBean id="inB" class="infoBean" scope="request">
>     <jsp:setProperty name="inB" property="location"/>
>     <jsp:setProperty name="inB" property="title"/>
></jsp:useBean>
>
><%
>     ArrayList loc = (ArrayList) inB.getLocationList();
>
>  String[] node = new String[3];
>  boolean test = false;
>  String loca = new String(inB.getLocation());
>
>  if( loca.equals("Product Team")) {
>     node[0] = "Fpa";
>     node[1] = "Fa";
>     node[2] = "Fb";
>     test = true;
>     }
>%>
>
><FORM action="index.jsp" name="newgam" method="post" >
><TABLE>
>    <TR><TD>Title:</TD>
>         <TD><INPUT type="text" name="title" value="<jsp:getProperty
> name="inB" property="title" />"></TD>
>    </TR>
>         <TD>Location:</TD>
>         <TD><SELECT name="location" size="1"
> onchange="document.newgam.submit();" >
>              <OPTION>--------------------</OPTION>
>         <%  for (int i=0; i < loc.size(); i++) {
>          if (loca.equals(loc.get(i))) { %>
>          <OPTION SELECTED><%= loc.get(i) %></OPTION>
>          <% } else { %>
>                 <OPTION><%= loc.get(i) %></OPTION>
>                  <% }
>             } %>
>         </SELECT></TD>
>    </TR>
>    <TR><TD>Node:</TD>
>        <TD><SELECT name="node" size="1" >"
>         <OPTION>-----------------</OPTION>
>         <% if (test) {
>              for (int i=0; i < node.length; i++) { %>
>                 <OPTION  ><%= node[i] %></OPTION>
>                  <% }
>         }
>
>
>         %>
>       </SELECT></TD>
>    </TR>
>    <TR><TD>
>       <INPUT type="SUBMIT" ></TD>
>    </TR>
></TABLE>
><sql:connection id="con1" >
>      <sql:driver>oracle.jdbc.driver.OracleDriver</sql:driver>
>      <sql:url>jdbc:oracle:thin:@enaoracle1:1521:one</sql:url>
></sql:connection>
>
><TABLE>
><sql:statement id="stmt1" conn="con1">
>     <sql:query>
>         select * from location
>     </sql:query>
>     <sql:resultSet id="rset2">
>         <tr>
>            <td><sql:getColumn position="1"/></td>
>            <td><sql:getColumn position="2"/></td>
>         </tr>
>    </sql:resultSet>
></sql:statement>
></TABLE>
>
>
><sql:closeConnection conn="con1"/>
></FORM>
>
>
>Thanks for any help that I can get.
>
>Ajay
>
>===========================================================================
>To unsubscribe: mailto [EMAIL PROTECTED] with body: "signoff
>JSP-INTEREST".
>For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".
>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".
For digest: mailto [EMAIL PROTECTED] with body: "set JSP-INTEREST DIGEST".
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