| Author |
How to Display Database Values in Javascript table
|
Ananth sunraj
Greenhorn
Joined: Sep 05, 2008
Posts: 12
|
|
Hi, Can anyone suggest me ideas for populating the table with Database values using javascript and Ajax. Rather than using <td><% rs.getString(1)%></td> like. Thanks in Advance
|
 |
Jair Rillo Junior
Ranch Hand
Joined: Aug 27, 2008
Posts: 114
|
|
You can use any framework to do that, I like DWR. It is simple and easy to use. The code to retrieve the data from database will be a Java class, and the AJAX will request those values from this Java code and then display them on the HTML without Scriptlets.
|
Regards, Jair Rillo Junior
http://www.jairrillo.com/blog, SCJA 1.0, SCJP 1.4, SCWCD 1.4, SCBCD 5.0, IBM SOA Associate (Test 664).
|
 |
Jack Doson
Greenhorn
Joined: Oct 02, 2008
Posts: 9
|
|
Generally , we are not supposed(adviced) to write Data Base access code inside any Jsp..! Better way is to acces date base in any Bean(other java class) and pass that bean to jsp. access variable of that class in the jsp..! (general syntax is Instantiate bean in servlet....! set that bean as a attribute to request object..! DataBean databean=new DataBean(); request.setAttribute("result",databean); inside jsp.. <jsp:useBean id="result" scope="request" class="DataBean"/> <jsp:getProperty name="result" property="name"/> Specific Answer to your Question..! <% Class.forName("oracle.jdbc.driver.OracleDriver"); Connection con=DriverMananger.getConncetion("dburl","username","password"); Statement st=con.createStatement(); ResultSet rs=st.executeQuery(); rs.next();%> html code <%=rs.getString(1)%>[by using expression evaluter..!] html code <%=rs.getString(2)%>
|
Jack Dososn..!
|
 |
 |
|
|
subject: How to Display Database Values in Javascript table
|
|
|