Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
J
java_dzienna_15_09
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
java_dzienna_15_09
Commits
29a4687d
Commit
29a4687d
authored
Sep 29, 2022
by
Patryk Czarnik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
products4 - JSTL SQL
parent
1080f091
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
40 additions
and
0 deletions
+40
-0
products4.jsp
PC26-SklepWeb/src/main/webapp/products4.jsp
+40
-0
No files found.
PC26-SklepWeb/src/main/webapp/products4.jsp
0 → 100644
View file @
29a4687d
<
%@
page
language=
"java"
contentType=
"text/html; charset=UTF-8"
pageEncoding=
"UTF-8"
%
>
<
%@
taglib
prefix=
"c"
uri=
"http://java.sun.com/jsp/jstl/core"
%
>
<
%@
taglib
prefix=
"sql"
uri=
"http://java.sun.com/jsp/jstl/sql"
%
>
<!DOCTYPE html>
<html>
<head>
<meta
charset=
"UTF-8"
>
<title>
Lista produktów 4
</title>
<link
rel=
"stylesheet"
type=
"text/css"
href=
"styl.css"
>
</head>
<body>
<h1>
Lista produktów - wersja 4 JSP
</h1>
<p>
W tej wersji korzystamy ze standardowej biblioteki tagów (JSTL), a dokładnie z jej fragmentu obsługującego SQL.
</p>
<p>
Bezpośrednio w JSP wykonamy zapytanie w bazie danych - to też jeszcze nie będzie najładniejszy styl...
</p>
<
%
--
W
tej
wersji
za
pomoc
ą
dedykowanych
tag
ó
w
JSP
zadamy
zapytanie
SQL
.
Ta
wersja
W
OG
Ó
LE
nie
u
ż
ywa
klas
stworzonych
przez
nas
w
projekcie
;
jest
samowystarczalna
.
--
%
>
<
%
--
"
taglibs
"
-
biblioteki
tag
ó
w
,
zaimplementowane
w
Javie
,
a
w
JSP
u
ż
ywa
si
ę
ich
za
pomoc
ą
sk
ł
adni
"
tagowej
"
(
dok
ł
adnie
sk
ł
adni
XML
)
--
%
>
<sql:setDataSource
var=
"baza"
driver=
"org.postgresql.Driver"
url=
"jdbc:postgresql://localhost/sklep"
user=
"kurs"
password=
"abc123"
/>
<sql:query
dataSource=
"${baza}"
scope=
"page"
var=
"result"
>
SELECT * FROM products ORDER BY product_id
</sql:query>
<
%
--
.
product_name
.
price
itp
-
to
s
ą
nazwy
kolumn
w
tabeli
SQL
--
%
>
<c:forEach
var=
"row"
items=
"${result.rows}"
>
<div
class=
"product"
>
<h3>
${row.product_name}
</h3>
<div
class=
"price"
>
${row.price}
</div>
<p>
${row.description}
</p>
</div>
</c:forEach>
</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