0

I am new to Java EE. I am using a checkbox which is showing some technology field. Now I am trying to fetch specific data within a option tag from one table while clicking on a perticular technology field. I am using AJAX call to generate the dropdown box when clicking on a perticular technology but cannot fetch the specific data from the table. how can i do that in a jsp page. My Code is as follows

    <table bgcolor="#ffffff" class="style2">


        <tr>
            <td align="center" valign="middle">
                <select name="year">
                    <option value="Select">Select</option>>
                    <%
                                try {
                                    Class.forName("oracle.jdbc.driver.OracleDriver");
                                    Connection con = DriverManager.getConnection("jdbc:oracle:thin:@192.168.3.1:1521:wtlctax1", "****", "****");
                                    Statement stmt = con.createStatement();
                                    ResultSet rs = stmt.executeQuery("select exp_year.year from exp_year INNER JOIN technology ON exp_year.t_cd = technology.t_cd");

                                            while (rs.next()) {
                                                String str = rs.getString("year");
                                                String str1 = rs.getString("t_cd");
                    %>

                    <option value="<%=str%>"><%=str%></option>
                    <% } %>
                </select>
             </td>
        </tr>
        <%
                        }
                    catch (Exception e) {
                        System.out.println(e);
                    }

        %>
    </table>
Arjan Tijms
  • 37,782
  • 12
  • 108
  • 140
Suman Ghosh
  • 23
  • 2
  • 9
  • Can you be more specific at what you are trying to accomplish? By table are you referring to the database table or the html table? From my understanding, what you want is to make an ajax call and fetch some data, when a value is selected from the dropdown. Correct? – Dogoku Jan 11 '13 at 11:19
  • At least not this way. Start here: http://stackoverflow.com/questions/4112686/how-to-use-servlets-and-ajax/4113258#4113258 My downvote is by the way not for the exposed bad practices, but because the question is not clear at all, it's too much like "Bam, here's my code. It doesn't work. Please debug it". – BalusC Jan 11 '13 at 14:21
  • @Dogoku: Ya you are correct.. I want to do so.. But i can't do that. – Suman Ghosh Jan 14 '13 at 06:15
  • the question linked by BalusC is exactly what you are looking for. The accepted answer to that question, explains everything in detail. Hehe, i just noticed, BalusC answered that question. Good job man! – Dogoku Jan 14 '13 at 16:32
  • Thank You guys. Now the problem is solved. – Suman Ghosh Jan 15 '13 at 07:30

0 Answers0