ramyajayaraman
JSP,DB
1 Answer(s)      2 years and 5 months ago
Posted in : JSP-Servlet

How to store the resultset of a query in a hashtable n retrive it into a jsp textfield!!!!!!

datatable

Label value id applno 13434323 123 batchno 4334 123

The database table is similar to the diagram given above??now I want to retrive the value of application no and master no into a jsp page?for this I thought of storing the resultset of my query in a hashtable n retriving bt dont know hw to do it?can u help me??..

My query:"select * from datatable where id="'+id'""

I want to get the values here

Section A-Customer Details appli no (((value of appl no should come here)))) Batch No ((((value of batchno))))) can u send me the code for this!!!!!

View Answers

January 11, 2011 at 3:26 PM


Hi Friend,

Try this:

<%@page import="java.sql.*"%>
<%@page import="java.util.*"%>
<html>
<table>
<%
 Class.forName("com.mysql.jdbc.Driver");
           Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/test", "root", "root");
           Statement st=con.createStatement();
           ResultSet rs=st.executeQuery("select * from data where id=1");
           Hashtable table=new Hashtable();
           int i=0;
            while(rs.next()){
               table.put("Name",rs.getString("name"));
                table.put("Address",rs.getString("address"));

           }
    Set set = table.keySet();
    String str;
    Iterator itr = set.iterator();
    while (itr.hasNext()) {
      str = itr.next().toString();
      %>
    <tr><td><%=str%></td><td><input type="text" value="<%=table.get(str)%>"></td></tr>
    <%
    }
      %>
      </table>
      </html>

Thanks









Related Pages:
JSP,DB
JSP,DB  How to store the resultset of a query in a hashtable n retrive it into a jsp textfield!!!!!! datatable Label value id applno... no into a jsp page?for this I thought of storing the resultset of my query
JSP,DB,SERVLET
JSP,DB,SERVLET  I have a jsp page with 3 text fields name,age ,city.i populated these datas into a database table.I have another jsp page with 4 fields name, city , age and phone.Once the user enter the name, city and age should
JSP,DB,SERVLET
JSP,DB,SERVLET  hi thank you for your reply.With this code i can insert the data successfully into database but In ajax.jsp once i give the name;;;age and city are not automatically fetched......instead sumthing get filled
JSP,DB,SERVLET
JSP,DB,SERVLET  hi thank you for your reply.With this code i can insert the data successfully into database but once i give submit button in insert.jsp it should be forwarded to ajax.jsp.In ajax.jsp once i give the name;;;age
JSP,DB,SERVLET
JSP,DB,SERVLET  I have a jsp page called page1.jsp with 3 text fields... (page1servlet.java) and bean(page1bean.java).I have another jsp page(display.jsp... not populate the datas automatically from databse in jsp on entering name ...can u
code for jsp to db connection using jdbc
code for jsp to db connection using jdbc  please send me the code   Hi Friend, Try the following code: 1)form.html: <html> <form method="post" action="http://localhost:8080/examples/jsp/insert.jsp"> <
How to insert data from a combobox and textbox values into DB using JSP?
How to insert data from a combobox and textbox values into DB using JSP?  hi, How to insert a comb-box and a text box values in to DB using JSP? @DB... and textbox2? into MYSQL DB