Guest User

Untitled

a guest
Nov 16th, 2016
41
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. <%@ page import="java.io.*,java.util.*,java.sql.*"%>
  2. <%@ page import="javax.servlet.http.*,javax.servlet.*" %>
  3. <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
  4. <%@ taglib uri="http://java.sun.com/jsp/jstl/sql" prefix="sql"%>
  5.  
  6. <html>
  7. <head>
  8. <title>SELECT Operation</title>
  9. </head>
  10. <body>
  11.  
  12. <sql:setDataSource var="snapshot" driver="com.mysql.jdbc.Driver"
  13. url="jdbc:mysql://localhost/betatest"
  14. user="root" password="root"/>
  15.  
  16. <sql:query dataSource="${snapshot}" var="result">
  17. SELECT * from table1;
  18. </sql:query>
  19.  
  20. <table border="1" width="100%">
  21. <tr>
  22. <th>Student ID</th>
  23. <th>Course</th>
  24. </tr>
  25. <c:forEach var="row" items="${result.rows}">
  26. <tr>
  27. <td><c:out value="${row.student_id}"/></td>
  28. <td><c:out value="${row.course}"/></td>
  29. </tr>
  30. </c:forEach>
  31. </table>
  32.  
  33. </body>
  34. </html>
Add Comment
Please, Sign In to add comment