After scanning though some documentation , still i cant use the datatable in the jsp page
After scanning though some documentation , still i cant use the datatable in the jsp page
Hello everyone,
I am a newbie to programming. Recently i have setup a very simply jsp page(run on weblogic) which draw data from an oracle server using jndi and display the data in a table form.
i am very impressed by functionality of the datatable and want to use it in the jsp web.But I am missing of information of how to setting up a datatable in my webpage.
I have followed guideline in the documentation like the html should be well-defined etc.
But still cant use the datatable.
Any comment is highly appreciated.
Thanks.
Below is the souce code.
<!DOCTYPE html>
<%@ page contentType="text/html;charset=windows-1252"%>
<%@ page import="javax.naming.InitialContext" %>
<%@ page import="java.util.*" %>
<%@ page import="javax.sql.*" %>
testpage
Column 1
Column 2
Column 3
<%
InitialContext initialContext = new InitialContext();
javax.sql.DataSource ds = (javax.sql.DataSource)initialContext.lookup("jdbc.abc-ds");
java.sql.Connection conn = ds.getConnection();
String sql = "select * from test_table";
java.sql.ResultSet rs = null;
java.sql.Statement s = null;
java.sql.PreparedStatement pst = null ;
try{
s = conn.createStatement();
rs = s.executeQuery(sql);
%>
<%
while(rs.next() ){
%>
<%= rs.getString("a") %>
<%= rs.getString("b") %>
<%= rs.getString("c") %>
<%= rs.getString("d") %>
<%
}
%>
<%
}catch(Exception e){
e.printStackTrace();
}finally{
if(rs!=null) rs.close();
if(s!=null) s.close();
if(conn!=null) conn.close();
}
%>
$(document).ready( function () {
$('#table_id').dataTable();
} );
I am a newbie to programming. Recently i have setup a very simply jsp page(run on weblogic) which draw data from an oracle server using jndi and display the data in a table form.
i am very impressed by functionality of the datatable and want to use it in the jsp web.But I am missing of information of how to setting up a datatable in my webpage.
I have followed guideline in the documentation like the html should be well-defined etc.
But still cant use the datatable.
Any comment is highly appreciated.
Thanks.
Below is the souce code.
<!DOCTYPE html>
<%@ page contentType="text/html;charset=windows-1252"%>
<%@ page import="javax.naming.InitialContext" %>
<%@ page import="java.util.*" %>
<%@ page import="javax.sql.*" %>
testpage
Column 1
Column 2
Column 3
<%
InitialContext initialContext = new InitialContext();
javax.sql.DataSource ds = (javax.sql.DataSource)initialContext.lookup("jdbc.abc-ds");
java.sql.Connection conn = ds.getConnection();
String sql = "select * from test_table";
java.sql.ResultSet rs = null;
java.sql.Statement s = null;
java.sql.PreparedStatement pst = null ;
try{
s = conn.createStatement();
rs = s.executeQuery(sql);
%>
<%
while(rs.next() ){
%>
<%= rs.getString("a") %>
<%= rs.getString("b") %>
<%= rs.getString("c") %>
<%= rs.getString("d") %>
<%
}
%>
<%
}catch(Exception e){
e.printStackTrace();
}finally{
if(rs!=null) rs.close();
if(s!=null) s.close();
if(conn!=null) conn.close();
}
%>
$(document).ready( function () {
$('#table_id').dataTable();
} );
This discussion has been closed.
Replies
Allan