-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.jsp
More file actions
60 lines (50 loc) · 1.55 KB
/
Copy pathindex.jsp
File metadata and controls
60 lines (50 loc) · 1.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
<!doctype html public "-//w3c//dtd html 4.0 transitional//en"
"http://www.w3.org/TR/REC-html40/strict.dtd">
<!-- For SQL statements. -->
<%@ page import="java.sql.*" %>
<%@ 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>Artist Database</title>
<link rel="stylesheet" type="text/css" href="main.css">
</head>
<body>
<h1>My Favorite Artists</h1>
<a href="insert.jsp" class="button">Add Artist</a>
<br>
<br>
<!-- connect to databas and query full artist table -->
<sql:setDataSource var="music" driver="com.mysql.jdbc.Driver"
url="jdbc:mysql://localhost/music"
user="root" password="pass"/>
<sql:query dataSource="${music}" var="result">
SELECT * from artists order by name;
</sql:query>
<!-- show artists table -->
<table border="1" width="100%" class="dbTable">
<tr>
<th>Artist</th>
<th>Year Formed</th>
<th>Country</th>
<th class="edit">Edit</th>
</tr>
<c:forEach var="row" items="${result.rows}">
<tr>
<td><c:out value="${row.name}"/></td>
<td><c:out value="${row.yearformed}"/></td>
<td><c:out value="${row.country}"/></td>
<td class="edit">
<!-- buttons to edit or delete entry -->
<form action="EditArtist" method="post">
<button type="submit" name="edit" value="${row.artistID}">Edit</button>
</form>
<form action="DeleteArtist" method="post">
<button type="submit" name="delete" value="${row.artistID}">Delete</button>
</form>
</td>
</tr>
</c:forEach>
</table>
</body>
</html>