Share on Google+Share on Google+

ramyajayaraman
JSP,DB
1 Answer(s)      6 years and 3 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!!!!!

Ads

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 Tutorials/Questions & Answers:
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
Advertisements
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
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
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
Tutorials   
Java Spring Hibernate Struts Training fat image from db fat image from db fat image from db fat image from db unable to get value returned from javascript variable in page How to change image size before adding to mysql using jsp Design a registration.jsp page with input for user registration details Cart Quantity jsp servlet coding issue servlet,jsp login registration forms without database in ecalipse ide using hashmap to store the registraion details ? servlet,jsp login registration forms without database in ecalipse ide using hashmap to store the registraion details ? servlet,jsp login registration forms without database in ecalipse ide using hashmap to store the registraion details ? servlet,jsp login registration forms without database in ecalipse ide using hashmap to store the registraion details ? servlet,jsp login registration forms without database in ecalipse ide using hashmap to store the registraion details ? servlet,jsp login registration forms without database in ecalipse ide using hashmap to store the registraion details ? servlet,jsp login registration forms without database in ecalipse ide using hashmap to store the registraion details ? image pdf marking pdf marking Multiple image upload using JSP Read code from excel sheet and upload into database using JSP Student java about search engine Convert BLOB to PDF and save it to a location how to copy files from remote to local machine using SFTP SSL in java? Like Team viewer Socket and Servert -Jsp how to copy files from remote location to local using java? How To Store Multilple Images In MySQL database dynamically with image uploader and then retrieve them in image gallery using java how to create SOAP based web service in java? how to fetch data from mysql database table and draw a bar chart on that data using in jsp how to create users in LDAP using java? how to authenticate user using TIVOLI api in java? how to create users using IBM Tivoi API in jsp/servelet? Java/J2ee Please explain this code as many packages and classes are unknown to me .! how to download the uploaded folder files using jsp Login Query image is display from path of mysql database please reply the code to store dynamic fields in database? Reloading issue in jsp How to get Button Id ? calling one jap page from another jsp page login login Problem to get connection from DAO class to JDBC Page Loading Time Fix table's column's name row(1st row of the table) so that it does not move up when the table is scrolled up to view more rows below Sending hidden values

Ads

 
Advertisement null

Ads