Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
J
javab_20230928
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
javab_20230928
Commits
45bdfe9d
Commit
45bdfe9d
authored
Oct 18, 2023
by
Patryk Czarnik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
products2 - serwlet z HTMLem
parent
2483470b
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
149 additions
and
0 deletions
+149
-0
Products2.java
PC25-SklepWeb/src/main/java/sklep/web/Products2.java
+52
-0
styl.css
PC25-SklepWeb/src/main/webapp/styl.css
+97
-0
No files found.
PC25-SklepWeb/src/main/java/sklep/web/Products2.java
0 → 100644
View file @
45bdfe9d
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
(
"/products2"
)
public
class
Products2
extends
HttpServlet
{
@Override
protected
void
doGet
(
HttpServletRequest
requets
,
HttpServletResponse
response
)
throws
ServletException
,
IOException
{
response
.
setContentType
(
"text/html"
);
response
.
setCharacterEncoding
(
"UTF-8"
);
PrintWriter
out
=
response
.
getWriter
();
out
.
println
(
"""
<!DOCTYPE html>
<html>
<head>
<title>Lista produktów</title>
<link rel='stylesheet' type='text/css' href='styl.css'>
</head>
<body>
<h1>Produkty</h1>
"""
);
try
(
DBConnection
db
=
DBConnection
.
open
())
{
ProductDAO
productDAO
=
db
.
productDAO
();
List
<
Product
>
products
=
productDAO
.
readAll
();
for
(
Product
product
:
products
)
{
out
.
println
(
product
.
toHtml
());
}
}
catch
(
DBException
e
)
{
out
.
println
(
"Wielka bieda!"
);
out
.
print
(
"<pre>"
);
e
.
printStackTrace
(
out
);
out
.
print
(
"</pre>"
);
}
out
.
println
(
"</body></html>"
);
}
}
PC25-SklepWeb/src/main/webapp/styl.css
0 → 100644
View file @
45bdfe9d
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
;
}
div
.action
{
font-size
:
smaller
;
font-family
:
'Arial'
,
sans-serif
;
font-weight
:
bold
;
background-color
:
#DDDDDD
;
border
:
2px
#444466
outset
;
padding
:
6px
;
margin
:
4px
auto
4px
4px
;
max-width
:
200px
;
}
.action
:hover
{
background-color
:
#EEEEEE
;
border
:
2px
#4455CC
outset
;
}
.action
:active
{
background-color
:
#EEEEEE
;
border
:
2px
#CC4455
inset
;
}
.action
a
{
display
:
inline-block
;
color
:
inherit
;
text-decoration
:
none
;
width
:
100%
;
}
.action
a
:hover
{
color
:
#0000CC
;
}
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