-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpbmenu.jsp
executable file
·47 lines (40 loc) · 1.72 KB
/
pbmenu.jsp
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
<b>Categories Menu</b>
<p />
<%-- Import the java.sql package --%>
<%@ page import="java.sql.*"%>
<%-- -------- Open Connection Code -------- --%>
<%
Connection conn = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
try {
// Registering Postgresql JDBC driver with the DriverManager
Class.forName("org.postgresql.Driver");
// Open a connection to the database using DriverManager
conn = DriverManager.getConnection(
"jdbc:postgresql://localhost/Project1DB?" +
"user=postgres&password=postgres");
%>
<%-- -------- SELECT Statement Code -------- --%>
<%
// Create the statement
Statement statement = conn.createStatement();
// Use the created statement to SELECT
// the student attributes FROM the Student table.
rs = statement.executeQuery("SELECT name FROM categories");
} catch (SQLException e) {
// Wrap the SQL exception in a runtime exception to propagate
// it upwards
//out.println("Unable to perform operation specified on category.");
//throw new RuntimeException(e);
}
%>
<form action="products_browsing.jsp">
<input type="submit" name="action" value="All Products" style="height:20px; width:100px">
</form>
<% while (rs.next()) { %>
<form action="products_browsing.jsp">
<input type="submit" name="action" value=<%= rs.getString("name") %> style="height:20px; width:100px">
</form>
<!--<a href="products.jsp" value=<%= rs.getString("name") %>><%= rs.getString("name") %><a></li>-->
<%}%>