0
Write a JSP program to read the students data like roll number, name, email and marks from the database and display it in tabular format on web page

Mumbai University > Information Technology > Sem 4 > Web Programming

Marks: 10M

0  upvotes
0
<html>
<head>
<meta http-equiv="Content-Type"  content="text/html;charset=ISO-8859-1">
<title>Student details</title>
</head>
<body>
</body>
      <form method="post">
      <table border="2">
      <tr>
      <td>ROLL NUMBER</td>
      <td>NAME</td>
      <td>EMAIL</td>
      <td>MARKS</td> 
      </tr>
      <%
      try
      {
             Class.forName("com.mysql.jdbc.Driver");
             String url="jdbc:mysql://localhost/test";
             String username="root";
             String password="root";
             String query="select*from jsp1";
             Connection conn=DriverManager.getConnection(url,username,password);
             Statement stmt=conn.createStatement();
             ResultSet rs=stmt.executeQuery(query);
             while(rs.next())
      { 
      %>
             <tr>
             <td><%=rs.getInt("ROLL NUMBER")%></td>
             <td><%=rs.getInt("NAME")%></td>
             <td><%=rs.getInt("EMAIL")%></td>
             <td><%=rs.getInt("MARKS")%></td> 
             </tr>
      <%
      }
     %>
    </table>
   <%
   rs.close();
  stmt.close();
  conn.close();
        }
  catch(Exception e)
      {
  e.printStackTrace();
      }
     %>
 </form>
 </html>
0  upvotes
Please log in to add an answer.

Next up

Read More Questions

If you are looking for answer to specific questions, you can search them here. We'll find the best answer for you.

Search

Study Full Subject

If you are looking for good study material, you can checkout our subjects. Hundreds of important topics are covered in them.

Know More