Skip to content
Open

Cart #210

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/main/java/library/web/servlets/BookServlet.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ protected void doPost(HttpServletRequest request, HttpServletResponse response)
if(title!=null && !title.isEmpty() && publisher!=null && !publisher.isEmpty() && String.valueOf(year)!=null && !String.valueOf(year).isEmpty())
{
IDatabaseCatalog library = new HsqlDbCatalogFactory().library();



Book book = new Book();
book.setTitle(title);
book.setPublisher(publisher);
Expand All @@ -48,6 +49,10 @@ protected void doPost(HttpServletRequest request, HttpServletResponse response)
out.println("Available: " + book.isAvailable());

out.println("Added book to db");




}
}
}
40 changes: 40 additions & 0 deletions src/main/webapp/Cart.jsp
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
<%@page import="java.util.*"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ page import="library.dao.repos.*" %>
<%@ page import="library.dao.repos.impl.*" %>
<%@ page import="library.domain.*" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
<ul>
<%


IDatabaseCatalog library = new HsqlDbCatalogFactory().library();
List<Book> booksForsession = new ArrayList<Book>();
booksForsession.addAll(library.books().getPage( 1, 10));
session.setAttribute("reservedBooks", booksForsession);

List<Book> booksFromSession = (List<Book>) session.getAttribute("reservedBooks");
for(Book b: booksForsession){%>
<td>ID: <%=b.getId()%></td>
<td>Title: <%=b.getTitle()%></td>
<td>Publisher: <%=b.getPublisher() %></td>
<td>Year: <%=b.getYear()%></td><button type="delete"<%=booksForsession.remove(b.getId())%>>usun</button><br>
<%
}
%>





</ul>
</body>
</html>