Skip to content

Instantly share code, notes, and snippets.

@quickgrid
Last active October 19, 2016 20:54
Show Gist options
  • Save quickgrid/4401a5023b5fbb114362f6e3e7e696b9 to your computer and use it in GitHub Desktop.
Save quickgrid/4401a5023b5fbb114362f6e3e7e696b9 to your computer and use it in GitHub Desktop.
<%@ page import="java.io.*,java.util.*,java.sql.*"%>
<%@ page import="javax.servlet.http.*,javax.servlet.*" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/sql" prefix="sql"%>
<html>
<head>
<title>SELECT Operation</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.0.0-alpha.5/css/bootstrap.min.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/4.0.0-alpha.5/js/bootstrap.min.js"></script>
</head>
<body>
<sql:setDataSource var="snapshot" driver="com.mysql.jdbc.Driver"
url="jdbc:mysql://localhost/YOURDATABASENAME"
user="root" password="yourPassword"/>
<sql:query dataSource="${snapshot}" var="result">
SELECT * from course;
</sql:query>
<table border="1" width="100%" class="table table-hover table-inverse">
<tr>
<th>Course ID</th>
<th>Course Title</th>
<th>Department Name</th>
<th>Credits</th>
</tr>
<c:forEach var="row" items="${result.rows}">
<tr>
<td><c:out value="${row.course_id}"/></td>
<td><c:out value="${row.title}"/></td>
<td><c:out value="${row.dept_name}"/></td>
<td><c:out value="${row.credits}"/></td>
</tr>
</c:forEach>
</table>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment