Click here to Skip to main content
15,889,595 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
    pageEncoding="ISO-8859-1"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>

 <link rel="stylesheet" href="https://cdn.datatables.net/1.10.16/css/jquery.dataTables.min.css">
 <script src="https://code.jquery.com/jquery-3.3.1.js"></script>
 <script src="https://cdn.datatables.net/1.10.16/js/jquery.dataTables.min.js"></script>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>User List</title>

 
  
   
</head>
<body>
<h3>User List:-</h3>
<%@page import ="java.sql.*" %>
<% 
String ademail=request.getParameter("aemail");
String adpass=request.getParameter("apass");

if(ademail.equals("admin")&& adpass.equals("admin")){
	session.setAttribute("user",ademail);  
Class.forName("com.mysql.jdbc.Driver");
Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/jsp",
        "root", "");
Statement st = con.createStatement();

ResultSet rs=st.executeQuery("select * from login");  


//out.println(rs.getInt(1)+"  "+rs.getString(2)+"  "+rs.getString(3)+"<br>");  
//con.close();
    out.print("<div class='container-fluid'>");
    out.print("<div class='table-responsive col-md-12'  style='width:70%'>");
	out.print("<table border='1'  id='example' class='table table-hover nowrap'cellpadding='4' width='60%'>");  
	out.print("<thread><tr><th>Id</th><th>Name</th><th>Email</th></thread>"); 
	while(rs.next())  {
	 out.print("<tbody><tr><td>"+rs.getInt(1)+"</td> <td>"+rs.getString(2)+"</td> <td>"+rs.getString(3)+"</td></tr></tbody>");

	}
	out.print("</table></div>");
	out.print("</div>");
	
}else
{
	response.sendRedirect("admin.jsp");
}
%>
</body>
<script type="text/javascript">

$(document).ready(function() {
    $('#example').DataTable( {
    	 "pagingType": "full_numbers",
    	 "paging": true,
    	 "lengthChange": true,
         "searching": true,
         "ordering": true,
         "info": true,
         "autoWidth": true	
    	
    });
} );
	
</script>
</html>


What I have tried:

This is my source code, please tell me if there is any problem with cdn or anything else. I'm new to java, please help me
Posted
Updated 30-May-18 23:01pm

1 solution

Please define "not working".

It is your datatable and page so that nobody else can access it.

You have to get meaningful error message to know what went wrong. That includes checking the parameters (are they present and valid), catching exceptions (like SQLException (Java Platform SE 7 )[^] thrown by database access functions), and checking return values of functions which indicate errors through the return value rather than throwing exceptions.

By the way: There is no thread HTML tag (should be probably thead).
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900