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
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
Please log in to add an answer.

Continue reading

Find answer to specific questions by searching them here. It's the best way to discover useful content.

Find more