Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
2
20240528-BJava
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Patryk Czarnik
20240528-BJava
Commits
543e639f
Commit
543e639f
authored
Jun 12, 2024
by
Patryk Czarnik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Odczyt poprzez beana - wersja z listą
parent
01403b88
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
43 additions
and
1 deletions
+43
-1
ProductBean.java
PC24-SklepWeb/src/main/java/sklep/web/ProductBean.java
+21
-0
index.html
PC24-SklepWeb/src/main/webapp/index.html
+1
-1
products5a.jsp
PC24-SklepWeb/src/main/webapp/products5a.jsp
+21
-0
No files found.
PC24-SklepWeb/src/main/java/sklep/web/ProductBean.java
0 → 100644
View file @
543e639f
package
sklep
.
web
;
import
sklep.db.DBConnection
;
import
sklep.db.DBException
;
import
sklep.db.ProductDAO
;
import
sklep.model.Product
;
import
java.util.List
;
/* Ta klasa jest po to, aby w skrypcie JSP w wygodny sposób odczytać sobie listę produktów z bazy danych. */
public
class
ProductBean
{
// Metoda wygląda jak getter, ale wewnętrznie czyta dane z bazy, a nie z własnej zmiennej.
public
List
<
Product
>
getAllProducts
()
throws
DBException
{
try
(
DBConnection
db
=
DBConnection
.
open
())
{
ProductDAO
productDAO
=
db
.
productDAO
();
return
productDAO
.
readAll
();
}
}
}
PC24-SklepWeb/src/main/webapp/index.html
View file @
543e639f
...
@@ -20,7 +20,7 @@
...
@@ -20,7 +20,7 @@
<h3>
Wersje przyzwoite ;-)
</h3>
<h3>
Wersje przyzwoite ;-)
</h3>
<ul>
<ul>
<li><a
href=
"products5.jsp"
>
wersja 5
</a>
- JSP oparty o klasę bean
</li>
<li><a
href=
"products5
a
.jsp"
>
wersja 5
</a>
- JSP oparty o klasę bean
</li>
<li><a
href=
"products6.jsp"
>
wersja 6
</a>
- wyszukiwanie wg ceny - bean
</li>
<li><a
href=
"products6.jsp"
>
wersja 6
</a>
- wyszukiwanie wg ceny - bean
</li>
<li><a
href=
"products7.jsp"
>
wersja 7
</a>
- fotki
</li>
<li><a
href=
"products7.jsp"
>
wersja 7
</a>
- fotki
</li>
<li><a
href=
"products8.jsp"
>
wersja 8
</a>
- koszyk
</li>
<li><a
href=
"products8.jsp"
>
wersja 8
</a>
- koszyk
</li>
...
...
PC24-SklepWeb/src/main/webapp/products5a.jsp
0 → 100644
View file @
543e639f
<
%@
page
contentType=
"text/html;charset=UTF-8"
language=
"java"
%
>
<
%@
taglib
prefix=
"c"
uri=
"jakarta.tags.core"
%
>
<!DOCTYPE html>
<html>
<head>
<meta
charset=
"UTF-8"
>
<title>
Lista produktów 5
</title>
</head>
<body>
<h1>
Lista produktów - wersja 5
</h1>
<jsp:useBean
id=
"bean"
class=
"sklep.web.ProductBean"
/>
<
%
--
tak
jakby
for
(
Product
product
:
bean
.
getAllProducts
())
--
%
>
<ul>
<c:forEach
var=
"product"
items=
"${bean.allProducts}"
>
<li>
${product}
</li>
</c:forEach>
</ul>
</body>
</html>
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment