Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
2
20230403
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
20230403
Commits
17e55b73
Commit
17e55b73
authored
Apr 06, 2023
by
Patryk Czarnik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
products1 - odczyt za pomocą klas DAO
parent
670e2084
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
141 additions
and
0 deletions
+141
-0
Products1.java
PC25-SklepWeb/src/main/java/sklep/web/Products1.java
+38
-0
index.html
PC25-SklepWeb/src/main/webapp/index.html
+39
-0
styl.css
PC25-SklepWeb/src/main/webapp/styl.css
+64
-0
No files found.
PC25-SklepWeb/src/main/java/sklep/web/Products1.java
0 → 100644
View file @
17e55b73
package
sklep
.
web
;
import
java.io.IOException
;
import
java.io.PrintWriter
;
import
java.util.List
;
import
jakarta.servlet.ServletException
;
import
jakarta.servlet.annotation.WebServlet
;
import
jakarta.servlet.http.HttpServlet
;
import
jakarta.servlet.http.HttpServletRequest
;
import
jakarta.servlet.http.HttpServletResponse
;
import
sklep.db.DBConnection
;
import
sklep.db.DBException
;
import
sklep.db.ProductDAO
;
import
sklep.model.Product
;
@WebServlet
(
"/products1"
)
public
class
Products1
extends
HttpServlet
{
private
static
final
long
serialVersionUID
=
1L
;
protected
void
doGet
(
HttpServletRequest
request
,
HttpServletResponse
response
)
throws
ServletException
,
IOException
{
response
.
setContentType
(
"text/plain"
);
response
.
setCharacterEncoding
(
"UTF-8"
);
PrintWriter
out
=
response
.
getWriter
();
try
(
DBConnection
db
=
DBConnection
.
open
())
{
ProductDAO
productDAO
=
db
.
productDAO
();
List
<
Product
>
products
=
productDAO
.
readAll
();
out
.
println
(
"Odczytano "
+
products
.
size
()
+
" produktów:"
);
for
(
Product
product
:
products
)
{
out
.
println
(
product
);
}
}
catch
(
DBException
e
)
{
e
.
printStackTrace
(
out
);
}
}
}
PC25-SklepWeb/src/main/webapp/index.html
0 → 100644
View file @
17e55b73
<!DOCTYPE html>
<html>
<head>
<meta
charset=
"UTF-8"
>
<title>
Sklep - spis treści
</title>
<link
rel=
"stylesheet"
type=
"text/css"
href=
"styl.css"
>
</head>
<body>
<h1>
Sklep Web
</h1>
<h2>
Lista produktów w różnych wersjach
</h2>
<h3>
Wersje niedoskonałe, nie do naśladowania.
</h3>
<ul>
<li><a
href=
"Products0"
>
wersja 0
</a>
- samodzielny prosty serwlet
</li>
<li><a
href=
"Products1"
>
wersja 1
</a>
- serwlet oparty o klasy DAO
</li>
<li><a
href=
"Products2"
>
wersja 2
</a>
- serwlet oparty o klasy DAO z HTMLem
</li>
<li><a
href=
"products3.jsp"
>
wersja 3
</a>
- JSP ze skryptletami
</li>
<li><a
href=
"products4.jsp"
>
wersja 4
</a>
- JSP z tagami SQL
</li>
</ul>
<h3>
Wersje przyzwoite ;-)
</h3>
<ul>
<li><a
href=
"products5.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=
"products7.jsp"
>
wersja 7
</a>
- fotki
</li>
<li><a
href=
"products8.jsp"
>
wersja 8
</a>
- koszyk
</li>
<li><a
href=
"products9.jsp"
>
wersja 9
</a>
- edycja produktów
</li>
</ul>
<h3>
Dodatkowe strony
</h3>
<ul>
<li><a
href=
"Photo?productId=2"
>
Foto
</a>
- przykładowe zdjęcie
</li>
<li><a
href=
"upload_photo.jsp?productId=2"
>
Zmień zdjęcie
</a>
nr 2
</li>
<li><a
href=
"EditProduct?productId=1"
>
Edytuj produkt nr 1
</a></li>
<li><a
href=
"EditProduct"
>
Dodaj nowy produkt
</a></li>
</ul>
</body>
</html>
PC25-SklepWeb/src/main/webapp/styl.css
0 → 100644
View file @
17e55b73
body
{
background-color
:
#FFFFDD
;
font-family
:
'Arial'
,
sans-serif
;
}
/* komentarz w CSS */
h4
{
text-align
:
center
;
}
h2
,
h3
,
h4
{
margin-top
:
0
;
}
.product
{
border
:
solid
2px
blue
;
margin
:
1em
auto
1em
50px
;
padding
:
1em
;
background-color
:
white
;
width
:
800px
;
min-height
:
230px
;
clear
:
right
;
}
.koszyk
{
position
:
fixed
;
right
:
0
;
top
:
0
;
width
:
300px
;
height
:
400px
;
background-color
:
white
;
border
:
outset
3px
green
;
}
#wyszukiwarka
{
background-color
:
#AAEEFF
;
width
:
800px
;
border
:
2px
black
solid
;
margin
:
1em
400px
1em
50px
;
padding
:
1em
;
}
.error
{
background-color
:
#FFFFFF
;
border
:
6px
double
red
;
margin
:
20px
;
padding
:
10px
;
color
:
red
;
}
.photo
{
display
:
block
;
float
:
right
;
max-width
:
300px
;
max-height
:
200px
;
margin
:
5px
;
}
.description
{
font-size
:
smaller
;
font-style
:
italic
;
}
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