I get lot of queries to have a simple example to Display database value in jsp page.
So i provide the code below for the users benefit.Here i use the database as mysql,if you are using different database change the connection coding accordingly.To work this example in tomcat create a web.xml file and place this coding file inside the folder
<%@ page import="java.sql.*"%>
<%
Class.forName("com.mysql.jdbc.Driver");
Connection con=DriverManager.getConnection("jdbc:mysql://localhost/way2start","root","root");
Statement st=con.createStatement();
ResultSet rs=st.executeQuery("select * from one");
while(rs.next())
{
out.println("<html>");
out.println("<body>");
out.println("<table bgcolor='green'>");
out.println("<tr>");
out.println("<td>");
out.println(rs.getString(1));
out.println("</td>");
out.println("</tr>");
out.println("</table>");
out.println("</body>");
out.println("</html>");
}
%>
Tutorial Provided by In order to view links, you must have to reply to this thread. Visit for More Tutorials
Any doubt ask us.
Happy coding