I hv been developing a database access application thru servlets. I hv one
combo box with data obtained from database. Now the second combo-box should
hv data based on the selection in first combo-box or in other words should
be filtered. The application meets IndexArrayOutOfBound exeception on run.


package budget;

import java.io.*;
import java.sql.*;
import javax.servlet.*;
import javax.servlet.http.*;

public class expentry extends HttpServlet {
  String dbaseserver="172.16.1.50";
   String drv="ids.sql.IDSDriver";
String jdbcurl="jdbc:ids://" + dbaseserver+
":12/conn?dbtype=odbc&dsn=BUDGET";
ResultSet rs,rs1,rs2;
Statement st,st1,st2,st3;


    public void init()throws ServletException{
        super.init();
    }

    public void doGet(HttpServletRequest req,HttpServletResponse res)throws
ServletException,IOException{

     PrintStream out;
     Connection conn;

     out=new PrintStream(res.getOutputStream());
     res.setContentType("text/html");
     out.println("<html><head><title>Expenditure Entry
Screen</title></head>");
     out.println("<script language=javascript>");
     out.println("function selzn(n){");

     out.println("document.forms[0].submit();");
      out.println("}</script>" );

     out.println("<body>");

     out.println("<form >");
     try{
        Class.forName(drv);
        conn=DriverManager.getConnection(jdbcurl);

//Combobox for zone
        st=conn.createStatement();
        rs=st.executeQuery("select * from zone");
        out.println("Select Zone:");
        out.println("<select name=cmbzone
onChange='selzn(this.selectedIndex)';>");
        while(rs.next()){
            out.println("<option value=" +
rs.getString(2)+">"+rs.getString(2));
        }
        out.println("</select>");
    out.println("<br>");
//Combobox for station
--------------->Problem area
       String stnsql="SELECT STATION.[STATION_ NAME] FROM STATION WHERE
STATION.ZONE='"+ req.getParameter("cmbzone")+"'";
        out.println(stnsql);

         st=conn.createStatement();
        rs=st.executeQuery(stnsql);
        out.println("Select Station:");
        out.println("<select name=cmbzone>");
        while(rs.next()){
            out.println("<option>"+rs.getString(2));
        }
                out.println("</select>");
                out.println("<br>");



     }
     catch(SQLException ex){
        out.println("SQL Exception caught");
        out.println("Message:" +ex.getMessage());
     }
     catch(ClassNotFoundException e){
    out.println("<hr><h3>ClassNotFoundException caught</h3>");
    out.println("Message:" + e.getMessage());
}
out.println("</form></body></html>");
    }
}

Could anybody spare some time to help me.
Thanks in advance
Sanjeev

______________________________________________________
Get Your Private, Free Email at http://www.hotmail.com

___________________________________________________________________________
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff SERVLET-INTEREST".

Archives: http://archives.java.sun.com/archives/servlet-interest.html
Resources: http://java.sun.com/products/servlet/external-resources.html
LISTSERV Help: http://www.lsoft.com/manuals/user/user.html

Reply via email to