Commit 7ef68fca authored by Scafaru Luminita (Student Com20)'s avatar Scafaru Luminita (Student Com20)
Browse files

Final project aebi

parents
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry exported="true" kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-10">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" path="src/main/java"/>
<classpathentry exported="true" kind="con" path="org.eclipse.jst.j2ee.internal.web.container"/>
<classpathentry kind="con" path="org.eclipse.jst.j2ee.internal.module.container"/>
<classpathentry kind="con" path="org.eclipse.jst.server.core.container/org.eclipse.jst.server.tomcat.runtimeTarget/Apache Tomcat v10.0">
<attributes>
<attribute name="owner.project.facets" value="jst.web"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="build/classes"/>
</classpath>
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>AEBI3</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.wst.common.project.facet.core.builder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>org.eclipse.wst.validation.validationbuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jem.workbench.JavaEMFNature</nature>
<nature>org.eclipse.wst.common.modulecore.ModuleCoreNature</nature>
<nature>org.eclipse.wst.common.project.facet.core.nature</nature>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>org.eclipse.wst.jsdt.core.jsNature</nature>
</natures>
</projectDescription>
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry excluding="**/bower_components/*|**/node_modules/*|**/*.min.js" kind="src" path="src/main/webapp"/>
<classpathentry kind="con" path="org.eclipse.wst.jsdt.launching.JRE_CONTAINER"/>
<classpathentry kind="con" path="org.eclipse.wst.jsdt.launching.WebProject">
<attributes>
<attribute name="hide" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.wst.jsdt.launching.baseBrowserLibrary"/>
<classpathentry kind="output" path=""/>
</classpath>
eclipse.preferences.version=1
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
org.eclipse.jdt.core.compiler.codegen.targetPlatform=10
org.eclipse.jdt.core.compiler.compliance=10
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
org.eclipse.jdt.core.compiler.release=enabled
org.eclipse.jdt.core.compiler.source=10
<?xml version="1.0" encoding="UTF-8"?><project-modules id="moduleCoreId" project-version="1.5.0">
<wb-module deploy-name="AEBI">
<wb-resource deploy-path="/" source-path="/src/main/webapp" tag="defaultRootSource"/>
<wb-resource deploy-path="/WEB-INF/classes" source-path="/src/main/java"/>
<property name="java-output-path" value="/AEBI/build/classes"/>
<property name="context-root" value="AEBI"/>
</wb-module>
</project-modules>
<?xml version="1.0" encoding="UTF-8"?>
<faceted-project>
<runtime name="Apache Tomcat v10.0"/>
<fixed facet="java"/>
<fixed facet="wst.jsdt.web"/>
<fixed facet="jst.web"/>
<installed facet="java" version="10"/>
<installed facet="jst.web" version="4.0"/>
<installed facet="wst.jsdt.web" version="1.0"/>
</faceted-project>
org.eclipse.wst.jsdt.launching.baseBrowserLibrary
\ No newline at end of file
Window
\ No newline at end of file
Manifest-Version: 1.0
Class-Path:
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ page import ="java.sql.Connection" %>
<%@ page import ="java.sql.DriverManager" %>
<%@ page import ="java.sql.PreparedStatement" %>
<%@ page import ="java.sql.ResultSet" %>
<%@ page import ="java.util.UUID" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
<%
// Parameter lesen
String newTitle = request.getParameter("title");
int newYear = Integer.parseInt(request.getParameter("jahr"));
Class.forName("org.postgresql.Driver");
String url = "jdbc:postgresql://localhost/Aebi1?port=5432&user=postgres&password=123456";
Connection c = DriverManager.getConnection(url);
UUID id = UUID.randomUUID();
PreparedStatement pst= c.prepareStatement("INSERT INTO books(id, title, year) VALUES (? ,?, ?)");
pst.setObject(1, id);
pst.setString(2, newTitle);
pst.setInt(3, newYear);
pst.execute();
//wenn du ein neues Buch hinzufügst, dann bist du sofort zu dem index.jsp Seite redirect
response.sendRedirect("index.jsp");
%>
<!--<p>New book inserted!</p>
<p><a href="index.jsp">Go back.</a>-->
</body>
</html>
\ No newline at end of file
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ page import ="java.sql.Connection" %>
<%@ page import ="java.sql.DriverManager" %>
<%@ page import ="java.sql.PreparedStatement" %>
<%@ page import ="java.sql.ResultSet" %>
<%@ page import ="java.util.UUID" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
<%
UUID bookToDelete = UUID.fromString(request.getParameter("book"));
Class.forName("org.postgresql.Driver");
String url = "jdbc:postgresql://localhost/Aebi1?port=5432&user=postgres&password=123456";
Connection c = DriverManager.getConnection(url);
//WICHTIHG PART!!--> PreparedStatement
PreparedStatement pst= c.prepareStatement("DELETE FROM books WHERE id = ?");
pst.setObject(1, bookToDelete);
pst.execute();
//es gibt eine andere Variante nicht zu vervenden!! Weil wir müssen nicht user data mit Sql mischen!
//Statement s = c.createStatement();
//s.execute("DELETE FROM books WHERE id ="+ request.getParameter("book"));
//wenn du ein neues Buch hinzufügst, dann bist du sofort zu dem index.jsp Seite redirect
response.sendRedirect("index.jsp");
%>
<!-- <p>Book </%//=bookToDelete %> was deleted.</p>
<p><a href="index.jsp">Go back.</a>-->
</body>
</html>
\ No newline at end of file
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ page import ="java.sql.Connection" %>
<%@ page import ="java.sql.DriverManager" %>
<%@ page import ="java.sql.PreparedStatement" %>
<%@ page import ="java.sql.ResultSet" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
<%
Class.forName("org.postgresql.Driver");
String url = "jdbc:postgresql://localhost/Aebi1?port=5432&user=postgres&password=123456";
Connection c = DriverManager.getConnection(url);
PreparedStatement pst= c.prepareStatement("SELECT id, title, year FROM books");
ResultSet result = pst.executeQuery();
%>
<p><a href="new.jsp">Neues Buch einfügen</a></p>
<table>
<tr>
<th>Title</th>
<th>Year</th><th></th><th></th>
</tr>
<%
while (result.next()) {
//Two ways
/*String line = "<tr><td style='width:200px'>"+
"$title</td><td style='width:100px'>$year</td><td>" +
"<a href='delete.jsp?book=$id'>LÖSCHEN</a></td></tr>";
// delete this because of UUID-->line = line.replace("$id", result.getString("id"));
line = line.replace("$title", result.getString("title"));
line = line.replace("$year", result.getString("year"));
out.println(line);*/
out.println("<tr>");
// delete this because of UUID --> out.println("<td style='font-weight:bold'>" + result.getString("id") + "</td>");
out.println("<td>" + result.getString("title") + "</td>");
out.println("<td>" + result.getString("year") + "</td>");
out.println("<td><a href='modify.jsp?book=" + result.getString("id") + "'>ÄNDERN</a></td>");
out.println("<td><a href='delete.jsp?book=" + result.getString("id") + "'>LÖSCHEN</a></td>");
out.println("</tr>");
}
c.close();
%>
<!-- nicht titel Bücher in postgres verändern, weil sondern kein UUID wird gemacht!
Erst Mal müssen wir der UUID in POstgres anmachen---
uuid_generate_v4()--to insert in constraints, default-->
</table>
</body>
</html>
\ No newline at end of file
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ page import ="java.sql.Connection" %>
<%@ page import ="java.sql.DriverManager" %>
<%@ page import ="java.sql.PreparedStatement" %>
<%@ page import ="java.sql.ResultSet" %>
<%@ page import ="java.util.UUID" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
<%
UUID bookToModify = UUID.fromString(request.getParameter("book"));
Class.forName("org.postgresql.Driver");
String url = "jdbc:postgresql://localhost/Aebi1?port=5432&user=postgres&password=123456";
Connection c = DriverManager.getConnection(url);
PreparedStatement pst= c.prepareStatement("SELECT id, title, year FROM books WHERE id = ?");
pst.setObject(1, bookToModify);
String currentID = "";
String currentTitle = "";
int currentYear = 0;
ResultSet result = pst.executeQuery();
if (result.next()) {
currentID = result.getString(1);
currentTitle = result.getString(2);
currentYear = result.getInt(3);
}
%>
<p>Buch ändern:</p>
<form action="update.jsp" method="get">
<input type="hidden" name= "id" value="<%=currentID %>"> <!-- hidden/unsichtbar, weil so können wir ein Buch ändern -->
<p>Titel:<input type="text" name="title" value="<%=currentTitle%>"></p>
<p>Jahr:<input type="text" name="jahr" value="<%=currentYear%>"></p>
<br/>
<div><input type="submit" value="Speichern"></div>
</form>
</body>
</html>
\ No newline at end of file
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
<p>Neues Buch:</p>
<form action="create.jsp" method="get">
<p>Titel:<input type="text" name="title"></p>
<p>Jahr:<input type="text" name="jahr"></p>
<br/>
<div><input type="submit" value="Speichern"></div>
</form>
</body>
</html>
\ No newline at end of file
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ page import ="java.sql.Connection" %>
<%@ page import ="java.sql.DriverManager" %>
<%@ page import ="java.sql.PreparedStatement" %>
<%@ page import ="java.sql.ResultSet" %>
<%@ page import ="java.util.UUID" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
<%
// Parameter lesen
UUID id = UUID.fromString(request.getParameter("id"));
String newTitle = request.getParameter("title");
int newYear = Integer.parseInt(request.getParameter("jahr"));
Class.forName("org.postgresql.Driver");
String url = "jdbc:postgresql://localhost/Aebi1?port=5432&user=postgres&password=123456";
Connection c = DriverManager.getConnection(url);
PreparedStatement pst= c.prepareStatement("UPDATE books SET title = ?, year = ? WHERE ID =?");
pst.setObject(3, id);
pst.setString(1, newTitle);
pst.setInt(2, newYear);
pst.execute();
//wenn du ein neues Buch hinzufügst, dann bist du sofort zu dem index.jsp Seite redirect
response.sendRedirect("index.jsp");
%>
<!--<p>New book inserted!</p>
<p><a href="index.jsp">Go back.</a>-->
</body>
</html>
\ No newline at end of file
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ page import ="java.sql.Connection" %>
<%@ page import ="java.sql.DriverManager" %>
<%@ page import ="java.sql.PreparedStatement" %>
<%@ page import ="java.sql.ResultSet" %>
<%@ page import ="java.util.UUID" %>
<%@ page import ="java.sql.Date" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
<%
// Parameter lesen
UUID user = UUID.fromString(request.getParameter("user"));
UUID book = UUID.fromString(request.getParameter("book"));
String dateAsString = request.getParameter("datum");
java.util.Date date1 = new java.text.SimpleDateFormat("dd.MM.yyyy").parse(dateAsString);
Class.forName("org.postgresql.Driver");
String url = "jdbc:postgresql://localhost/Aebi1?port=5432&user=postgres&password=123456";
Connection c = DriverManager.getConnection(url);
UUID id = UUID.randomUUID();
PreparedStatement pst= c.prepareStatement("INSERT INTO books_users (id, \"user\", book, return_date) "+" VALUES (? ,?, ?, ?);");
pst.setObject(1, id);
pst.setObject(2, user);
pst.setObject(3, book);
java.sql.Date date2 = new java.sql.Date(date1.getTime());
pst.setDate(4, date2);
pst.execute();
response.sendRedirect("index.jsp");
%>
</body>
</html>
\ No newline at end of file
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ page import ="java.sql.Connection" %>
<%@ page import ="java.sql.DriverManager" %>
<%@ page import ="java.sql.PreparedStatement" %>
<%@ page import ="java.sql.ResultSet" %>
<%@ page import ="java.util.UUID" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
<%
UUID loanToDelete = UUID.fromString(request.getParameter("loan"));
Class.forName("org.postgresql.Driver");
String url = "jdbc:postgresql://localhost/Aebi1?port=5432&user=postgres&password=123456";
Connection c = DriverManager.getConnection(url);
//WICHTIHG PART!!--> PreparedStatement
PreparedStatement pst= c.prepareStatement("DELETE FROM books_users WHERE id = ?");
pst.setObject(1, loanToDelete);
pst.execute();
//es gibt eine andere Variante nicht zu vervenden!! Weil wir müssen nicht user data mit Sql mischen!
//Statement s = c.createStatement();
//s.execute("DELETE FROM books WHERE id ="+ request.getParameter("book"));
//wenn du ein neues Buch hinzufügst, dann bist du sofort zu dem index.jsp Seite redirect
response.sendRedirect("index.jsp");
%>
<!-- <p>Book </%//=bookToDelete %> was deleted.</p>
<p><a href="index.jsp">Go back.</a>-->
</body>
</html>
\ No newline at end of file
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ page import ="java.sql.Connection" %>
<%@ page import ="java.sql.DriverManager" %>
<%@ page import ="java.sql.PreparedStatement" %>
<%@ page import ="java.sql.ResultSet" %>
<%@ page import ="java.util.Date" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
<%
Class.forName("org.postgresql.Driver");
String url = "jdbc:postgresql://localhost/Aebi1?port=5432&user=postgres&password=123456";
Connection c = DriverManager.getConnection(url);
PreparedStatement pst= c.prepareStatement(
"SELECT books_users.id, books.title AS book, users.name AS \"user\", return_date FROM books_users " +
"INNER JOIN books ON books.id = books_users.book " +
"INNER JOIN users ON users.id = books_users.user ORDER BY return_date DESC ");
ResultSet result = pst.executeQuery();
%>
<p><a href="new.jsp">Neuen Verleih einfügen</a></p>
<table>
<tr>
<th>Buch</th>
<th>User</th>
<th>Rückgabedatum</th><th></th><th></th>
</tr>
<%
while (result.next()) {
//Date d = result.getDate("return_date");
//String style = d.before(new Date()) ? "red" : "white";
out.println("<tr>");
out.println("<td>" + result.getString("book") + "</td>");
out.println("<td>" + result.getString("user") + "</td>");
out.println("<td>" + result.getString("return_date") + "</td>");
out.println("<td><a href='modify.jsp?loan=" + result.getString("id") + "'>ÄNDERN</a></td>");
out.println("<td><a href='delete.jsp?loan=" + result.getString("id") + "'>LÖSCHEN</a></td>");
out.println("</tr>");
}
c.close();
%>
</table>
</body>
</html>
\ No newline at end of file
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment