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
85ce2d12
Commit
85ce2d12
authored
May 26, 2023
by
Patryk Czarnik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
wklep_web
parent
d6f4f667
Hide whitespace changes
Inline
Side-by-side
Showing
23 changed files
with
1068 additions
and
0 deletions
+1068
-0
pom.xml
PC39-Wielomodulowy/pom.xml
+2
-0
pom.xml
PC39-Wielomodulowy/sklep_web/pom.xml
+37
-0
AddToBasket.java
...owy/sklep_web/src/main/java/sklep/basket/AddToBasket.java
+38
-0
Basket.java
...modulowy/sklep_web/src/main/java/sklep/basket/Basket.java
+47
-0
BasketInitialization.java
..._web/src/main/java/sklep/basket/BasketInitialization.java
+22
-0
ProductInBasket.java
...sklep_web/src/main/java/sklep/basket/ProductInBasket.java
+75
-0
EditProduct.java
...dulowy/sklep_web/src/main/java/sklep/web/EditProduct.java
+83
-0
ProductBean.java
...dulowy/sklep_web/src/main/java/sklep/web/ProductBean.java
+55
-0
Products0.java
...modulowy/sklep_web/src/main/java/sklep/web/Products0.java
+53
-0
Products1.java
...modulowy/sklep_web/src/main/java/sklep/web/Products1.java
+38
-0
Products2.java
...modulowy/sklep_web/src/main/java/sklep/web/Products2.java
+51
-0
sklep.properties
...elomodulowy/sklep_web/src/main/resources/sklep.properties
+9
-0
index.html
PC39-Wielomodulowy/sklep_web/src/main/webapp/index.html
+39
-0
product_form.jsp
...-Wielomodulowy/sklep_web/src/main/webapp/product_form.jsp
+48
-0
products3.jsp
PC39-Wielomodulowy/sklep_web/src/main/webapp/products3.jsp
+44
-0
products4.jsp
PC39-Wielomodulowy/sklep_web/src/main/webapp/products4.jsp
+40
-0
products5.jsp
PC39-Wielomodulowy/sklep_web/src/main/webapp/products5.jsp
+28
-0
products6.jsp
PC39-Wielomodulowy/sklep_web/src/main/webapp/products6.jsp
+42
-0
products7.jsp
PC39-Wielomodulowy/sklep_web/src/main/webapp/products7.jsp
+52
-0
products8.jsp
PC39-Wielomodulowy/sklep_web/src/main/webapp/products8.jsp
+65
-0
products9.jsp
PC39-Wielomodulowy/sklep_web/src/main/webapp/products9.jsp
+69
-0
styl.css
PC39-Wielomodulowy/sklep_web/src/main/webapp/styl.css
+97
-0
upload_photo.jsp
...-Wielomodulowy/sklep_web/src/main/webapp/upload_photo.jsp
+34
-0
No files found.
PC39-Wielomodulowy/pom.xml
View file @
85ce2d12
...
...
@@ -42,5 +42,6 @@
<module>
soap_api
</module>
<module>
soap_serwer
</module>
<module>
soap_klient
</module>
<module>
sklep_web
</module>
</modules>
</project>
\ No newline at end of file
PC39-Wielomodulowy/sklep_web/pom.xml
0 → 100644
View file @
85ce2d12
<project
xmlns=
"http://maven.apache.org/POM/4.0.0"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation=
"http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"
>
<modelVersion>
4.0.0
</modelVersion>
<parent>
<groupId>
pl.alx.kjava
</groupId>
<artifactId>
PC39-Wielomodulowy
</artifactId>
<version>
1.0
</version>
</parent>
<artifactId>
sklep_web
</artifactId>
<packaging>
war
</packaging>
<dependencies>
<dependency>
<groupId>
${project.groupId}
</groupId>
<artifactId>
baza
</artifactId>
<version>
${project.version}
</version>
</dependency>
<dependency>
<groupId>
jakarta.platform
</groupId>
<artifactId>
jakarta.jakartaee-web-api
</artifactId>
<version>
9.1.0
</version>
<scope>
provided
</scope>
</dependency>
<dependency>
<groupId>
javax.servlet
</groupId>
<artifactId>
jstl
</artifactId>
<version>
1.2
</version>
</dependency>
</dependencies>
<build>
<finalName>
${project.artifactId}
</finalName>
</build>
</project>
\ No newline at end of file
PC39-Wielomodulowy/sklep_web/src/main/java/sklep/basket/AddToBasket.java
0 → 100644
View file @
85ce2d12
package
sklep
.
basket
;
import
java.io.IOException
;
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
jakarta.servlet.http.HttpSession
;
import
sklep.db.DBConnection
;
import
sklep.db.ProductDAO
;
import
sklep.model.Product
;
@WebServlet
(
"/add_to_basket"
)
public
class
AddToBasket
extends
HttpServlet
{
private
static
final
long
serialVersionUID
=
1L
;
@Override
protected
void
doGet
(
HttpServletRequest
request
,
HttpServletResponse
response
)
throws
ServletException
,
IOException
{
try
{
int
productId
=
Integer
.
parseInt
(
request
.
getParameter
(
"productId"
));
try
(
DBConnection
db
=
DBConnection
.
open
())
{
ProductDAO
productDAO
=
db
.
productDAO
();
Product
product
=
productDAO
.
findById
(
productId
);
HttpSession
sesja
=
request
.
getSession
();
Basket
basket
=
(
Basket
)
sesja
.
getAttribute
(
"basket"
);
basket
.
addProduct
(
product
);
}
}
catch
(
Exception
e
)
{
// ignorujemy błędy
}
// Przekierowanie - każemy przeglądarce wejść pod ten adres.
response
.
sendRedirect
(
"products9.jsp"
);
}
}
PC39-Wielomodulowy/sklep_web/src/main/java/sklep/basket/Basket.java
0 → 100644
View file @
85ce2d12
package
sklep
.
basket
;
import
java.math.BigDecimal
;
import
java.util.Collection
;
import
java.util.Collections
;
import
java.util.HashMap
;
import
java.util.Map
;
import
sklep.model.Product
;
public
class
Basket
{
private
final
Map
<
Integer
,
ProductInBasket
>
elementy
=
new
HashMap
<>();
public
synchronized
void
addProduct
(
Product
product
,
int
quantity
)
{
if
(
elementy
.
containsKey
(
product
.
getProductId
()))
{
// jeśli w słowniku jest już taki element, to tylko zwiększamy ilość
elementy
.
get
(
product
.
getProductId
()).
increaseQuantity
(
quantity
);
}
else
{
// jeśli jeszcze nie ma, to tworzymy
elementy
.
put
(
product
.
getProductId
(),
new
ProductInBasket
(
product
.
getProductId
(),
product
.
getProductName
(),
product
.
getPrice
(),
quantity
));
}
}
public
synchronized
void
addProduct
(
Product
product
)
{
// "domyślną ilością, o którą zwiększamy, jest 1"
addProduct
(
product
,
1
);
}
public
synchronized
Collection
<
ProductInBasket
>
getElements
()
{
return
Collections
.
unmodifiableCollection
(
elementy
.
values
());
}
public
synchronized
BigDecimal
getTotalValue
()
{
return
getElements
().
stream
()
.
map
(
ProductInBasket:
:
getValue
)
.
reduce
(
BigDecimal
.
ZERO
,
BigDecimal:
:
add
);
}
@Override
public
synchronized
String
toString
()
{
return
"Koszyk o rozmiarze "
+
getElements
().
size
()
+
" i wartości "
+
getTotalValue
();
}
}
PC39-Wielomodulowy/sklep_web/src/main/java/sklep/basket/BasketInitialization.java
0 → 100644
View file @
85ce2d12
package
sklep
.
basket
;
import
jakarta.servlet.annotation.WebListener
;
import
jakarta.servlet.http.HttpSession
;
import
jakarta.servlet.http.HttpSessionEvent
;
import
jakarta.servlet.http.HttpSessionListener
;
@WebListener
public
class
BasketInitialization
implements
HttpSessionListener
{
public
void
sessionCreated
(
HttpSessionEvent
se
)
{
HttpSession
session
=
se
.
getSession
();
session
.
setMaxInactiveInterval
(
30
);
// sesja wygasa po pół minuty - tylko na potrzeby zajęć
session
.
setAttribute
(
"basket"
,
new
Basket
());
System
.
out
.
println
(
"Początek sesji "
+
session
.
getId
());
}
public
void
sessionDestroyed
(
HttpSessionEvent
se
)
{
System
.
out
.
println
(
"Koniec sesji "
+
se
.
getSession
().
getId
());
}
}
PC39-Wielomodulowy/sklep_web/src/main/java/sklep/basket/ProductInBasket.java
0 → 100644
View file @
85ce2d12
package
sklep
.
basket
;
import
java.math.BigDecimal
;
import
java.util.Objects
;
public
class
ProductInBasket
{
private
int
productId
;
private
String
productName
;
private
BigDecimal
price
;
private
int
quantity
;
public
ProductInBasket
(
int
productId
,
String
productName
,
BigDecimal
price
,
int
quantity
)
{
this
.
productId
=
productId
;
this
.
productName
=
productName
;
this
.
price
=
price
;
this
.
quantity
=
quantity
;
}
public
BigDecimal
getPrice
()
{
return
price
;
}
public
void
setPrice
(
BigDecimal
price
)
{
this
.
price
=
price
;
}
public
int
getQuantity
()
{
return
quantity
;
}
public
void
setQuantity
(
int
quantity
)
{
this
.
quantity
=
quantity
;
}
public
int
getProductId
()
{
return
productId
;
}
public
String
getProductName
()
{
return
productName
;
}
@Override
public
String
toString
()
{
return
"ElementKoszyka [productId="
+
productId
+
", productName="
+
productName
+
", price="
+
price
+
", quantity="
+
quantity
+
"]"
;
}
@Override
public
int
hashCode
()
{
return
Objects
.
hash
(
price
,
productId
,
productName
,
quantity
);
}
@Override
public
boolean
equals
(
Object
obj
)
{
if
(
this
==
obj
)
return
true
;
if
(
obj
==
null
)
return
false
;
if
(
getClass
()
!=
obj
.
getClass
())
return
false
;
ProductInBasket
other
=
(
ProductInBasket
)
obj
;
return
Objects
.
equals
(
price
,
other
.
price
)
&&
productId
==
other
.
productId
&&
Objects
.
equals
(
productName
,
other
.
productName
)
&&
quantity
==
other
.
quantity
;
}
public
BigDecimal
getValue
()
{
return
price
.
multiply
(
BigDecimal
.
valueOf
(
quantity
));
}
public
void
increaseQuantity
(
int
change
)
{
quantity
+=
change
;
}
}
PC39-Wielomodulowy/sklep_web/src/main/java/sklep/web/EditProduct.java
0 → 100644
View file @
85ce2d12
package
sklep
.
web
;
import
java.io.IOException
;
import
java.math.BigDecimal
;
import
jakarta.servlet.RequestDispatcher
;
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.db.RecordNotFound
;
import
sklep.model.Product
;
@WebServlet
(
"/edit_product"
)
public
class
EditProduct
extends
HttpServlet
{
private
static
final
long
serialVersionUID
=
1L
;
@Override
protected
void
doGet
(
HttpServletRequest
request
,
HttpServletResponse
response
)
throws
ServletException
,
IOException
{
String
parametrId
=
request
.
getParameter
(
"productId"
);
if
(
parametrId
!=
null
)
{
int
productId
=
Integer
.
parseInt
(
parametrId
);
try
(
DBConnection
db
=
DBConnection
.
open
())
{
ProductDAO
productDAO
=
db
.
productDAO
();
Product
product
=
productDAO
.
findById
(
productId
);
// Gdy do obiektu request dodamy atrybut, to stanie się on dostępny dla kolejnych komponentów
// naszej aplikacji, które będą obsługiwać to zapytanie.
// W tym przypadku skrypt JSP może odwoływać się do obiektu product.
// Obiekt request jest też nośnikiem danych, podobnie jak sesja i servletContext.
// To działa jak Model w Spring MVC.
// Tylko jeśli znajdę produkt, tylko wtedy dodaję go do requestu i JSP wyświetli jego dane.
// Jeśli parametru productId nie było lub produktu nie znaleziono, to wyświetli się pusty formularz.
request
.
setAttribute
(
"product"
,
product
);
}
catch
(
DBException
|
RecordNotFound
e
)
{
e
.
printStackTrace
();
}
}
// Forward to "wewnętrzne przekierowanie" obsługi zapytania do innego komponentu aplikacji.
// Tutaj "wyświetlamy" formularz edycji produktu.
RequestDispatcher
dispatcher
=
request
.
getRequestDispatcher
(
"product_form.jsp"
);
if
(
dispatcher
!=
null
)
dispatcher
.
forward
(
request
,
response
);
}
@Override
protected
void
doPost
(
HttpServletRequest
request
,
HttpServletResponse
response
)
throws
ServletException
,
IOException
{
// W tej wersji nie obsługujemy błędów - w razie błędu wyświetli się strona z wyjątkiem
// W przypadku braku ID zostanie utworzony nowy produkt, a w przypadku podania ID (gdy to była edycja istniejącego) - zostanie zastąpiony.
request
.
setCharacterEncoding
(
"UTF-8"
);
String
parametrId
=
request
.
getParameter
(
"productId"
);
Integer
productId
=
(
parametrId
==
null
||
parametrId
.
isEmpty
())
?
null
:
Integer
.
valueOf
(
parametrId
);
String
parametrPrice
=
request
.
getParameter
(
"price"
);
BigDecimal
price
=
new
BigDecimal
(
parametrPrice
);
String
parametrVat
=
request
.
getParameter
(
"vat"
);
BigDecimal
vat
=
(
parametrVat
==
null
||
parametrVat
.
isEmpty
())
?
null
:
new
BigDecimal
(
parametrVat
);
String
name
=
request
.
getParameter
(
"productName"
);
String
description
=
request
.
getParameter
(
"description"
);
Product
product
=
new
Product
(
productId
,
name
,
price
,
vat
,
description
);
try
(
DBConnection
db
=
DBConnection
.
open
())
{
ProductDAO
productDAO
=
db
.
productDAO
();
productDAO
.
save
(
product
);
db
.
commit
();
// Gdy udało się zapisać, to przejdziemy z powrotem do listy.
response
.
sendRedirect
(
"products9.jsp"
);
}
catch
(
DBException
e
)
{
e
.
printStackTrace
();
}
}
}
PC39-Wielomodulowy/sklep_web/src/main/java/sklep/web/ProductBean.java
0 → 100644
View file @
85ce2d12
package
sklep
.
web
;
import
java.math.BigDecimal
;
import
java.util.List
;
import
sklep.db.DBConnection
;
import
sklep.db.DBException
;
import
sklep.db.ProductDAO
;
import
sklep.model.Product
;
public
class
ProductBean
{
private
BigDecimal
minPrice
,
maxPrice
;
// Chociaż wewnętrznie zmienna jest typu BigDecimal, to gettery i settery napiszemy tak, jakby to były Stringi.
// Robimy to po to, aby w JSP zadziałało setProperty.
public
String
getMinPrice
()
{
return
minPrice
==
null
?
null
:
minPrice
.
toString
();
}
public
void
setMinPrice
(
String
minPrice
)
{
if
(
minPrice
==
null
||
minPrice
.
isEmpty
())
{
this
.
minPrice
=
null
;
}
else
{
this
.
minPrice
=
new
BigDecimal
(
minPrice
);
}
}
public
String
getMaxPrice
()
{
return
maxPrice
==
null
?
null
:
maxPrice
.
toString
();
}
public
void
setMaxPrice
(
String
maxPrice
)
{
if
(
maxPrice
==
null
||
maxPrice
.
isEmpty
())
{
this
.
maxPrice
=
null
;
}
else
{
this
.
maxPrice
=
new
BigDecimal
(
maxPrice
);
}
}
// Metoda odczytuje produkty zgodnie z ustawionymi wcześniej kryteriami (w tym przykładzie są to ceny, ale może być więcej filtrów).
public
List
<
Product
>
getFilteredProducts
()
throws
DBException
{
try
(
DBConnection
db
=
DBConnection
.
open
())
{
return
db
.
productDAO
().
findByPrice
(
minPrice
,
maxPrice
);
}
}
// 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
();
}
}
}
PC39-Wielomodulowy/sklep_web/src/main/java/sklep/web/Products0.java
0 → 100644
View file @
85ce2d12
package
sklep
.
web
;
import
java.io.IOException
;
import
java.io.PrintWriter
;
import
java.sql.Connection
;
import
java.sql.DriverManager
;
import
java.sql.ResultSet
;
import
java.sql.SQLException
;
import
java.sql.Statement
;
import
jakarta.servlet.ServletException
;
import
jakarta.servlet.annotation.WebServlet
;
import
jakarta.servlet.http.HttpServlet
;
import
jakarta.servlet.http.HttpServletRequest
;
import
jakarta.servlet.http.HttpServletResponse
;
@WebServlet
(
"/products0"
)
public
class
Products0
extends
HttpServlet
{
private
static
final
long
serialVersionUID
=
1L
;
/* W tej wersji serwlet wypisuje dane produktów tekstowo.
* W kodzie serwletu bezpośrednio korzytstamy z technologii bazodanowej JDBC,
* mamy tutaj fragment SQL, nazwy tabel, kolumn, odczyt pojedynczych pól...
*
* Na dłuższą metę tak się nie programuje: byłoby za dużo kodu, mieszalibyśmy wartwę webową z warstwą danych,
* mielibyśmy dużo duplikacji kodu pomiędzy różnymi klasami w aplikacji.
*/
protected
void
doGet
(
HttpServletRequest
request
,
HttpServletResponse
response
)
throws
ServletException
,
IOException
{
response
.
setContentType
(
"text/plain"
);
response
.
setCharacterEncoding
(
"UTF-8"
);
PrintWriter
out
=
response
.
getWriter
();
try
(
Connection
c
=
DriverManager
.
getConnection
(
"jdbc:postgresql://localhost/sklep"
,
"kurs"
,
"abc123"
);
Statement
stmt
=
c
.
createStatement
();
ResultSet
rs
=
stmt
.
executeQuery
(
"SELECT * FROM products"
))
{
while
(
rs
.
next
())
{
out
.
printf
(
"Produkt nr %d: %s za cenę %s."
,
rs
.
getInt
(
"product_id"
),
rs
.
getString
(
"product_name"
),
rs
.
getBigDecimal
(
"price"
));
String
opis
=
rs
.
getString
(
"description"
);
if
(
opis
!=
null
)
{
out
.
printf
(
" Opis: %s."
,
opis
);
}
out
.
println
();
}
}
catch
(
SQLException
e
)
{
e
.
printStackTrace
(
out
);
}
}
}
PC39-Wielomodulowy/sklep_web/src/main/java/sklep/web/Products1.java
0 → 100644
View file @
85ce2d12
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
);
}
}
}
PC39-Wielomodulowy/sklep_web/src/main/java/sklep/web/Products2.java
0 → 100644
View file @
85ce2d12
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
{
private
static
final
long
serialVersionUID
=
1L
;
protected
void
doGet
(
HttpServletRequest
request
,
HttpServletResponse
response
)
throws
ServletException
,
IOException
{
response
.
setContentType
(
"text/html"
);
response
.
setCharacterEncoding
(
"UTF-8"
);
PrintWriter
out
=
response
.
getWriter
();
out
.
println
(
"<!DOCTYPE html>"
);
out
.
println
(
"<html>"
);
out
.
println
(
"<head>"
);
out
.
println
(
"<title>Lista produktów</title>"
);
out
.
println
(
"<link rel='stylesheet' type='text/css' href='styl.css'>"
);
out
.
println
(
"</head>"
);
out
.
println
(
"<body>"
);
out
.
println
(
"<h1>Lista produktów</h1>"
);
try
(
DBConnection
db
=
DBConnection
.
open
())
{
ProductDAO
productDAO
=
db
.
productDAO
();
List
<
Product
>
products
=
productDAO
.
readAll
();
out
.
printf
(
"<div>Odczytano %d produktów</div>"
,
products
.
size
());
for
(
Product
product
:
products
)
{
out
.
println
(
product
.
toHtml
());
}
}
catch
(
DBException
e
)
{
out
.
println
(
"<pre class='error'>"
);
e
.
printStackTrace
(
out
);
out
.
println
(
"</pre>"
);
}
out
.
println
(
"</body>"
);
out
.
println
(
"</html>"
);
}
}
PC39-Wielomodulowy/sklep_web/src/main/resources/sklep.properties
0 → 100644
View file @
85ce2d12
url
=
jdbc:postgresql://localhost:5432/sklep
driver_class
=
org.postgresql.Driver
user
=
kurs
password
=
abc123
photo_dir
=
/home/patryk/sklep/foto
# Sciezki na Windows: albo piszemy slashe / , albo podwojne backslashe \\
# photo_dir=C:/Users/Patryk/Desktop/sklep/foto
# photo_dir=C:\\Users\\Patryk\\Desktop\\sklep\\foto
PC39-Wielomodulowy/sklep_web/src/main/webapp/index.html
0 → 100644
View file @
85ce2d12
<!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=
"edit_product?productId=1"
>
Edytuj produkt nr 1
</a></li>
<li><a
href=
"edit_product"
>
Dodaj nowy produkt
</a></li>
</ul>
</body>
</html>
PC39-Wielomodulowy/sklep_web/src/main/webapp/product_form.jsp
0 → 100644
View file @
85ce2d12
<
%@
page
language=
"java"
contentType=
"text/html; charset=UTF-8"
pageEncoding=
"UTF-8"
%
>
<
%@
taglib
prefix=
"c"
uri=
"http://java.sun.com/jsp/jstl/core"
%
>
<!DOCTYPE html>
<html>
<head>
<meta
charset=
"UTF-8"
>
<title>
Edycja danych produktu
</title>
<link
rel=
"stylesheet"
type=
"text/css"
href=
"styl.css"
>
</head>
<body>
<h1>
Edycja produktu
</h1>
<form
id=
"product-form"
method=
"post"
>
<table
class=
"form"
>
<tr>
<td><label
for=
"productId"
>
Numer:
</label></td>
<td><input
name=
"productId"
placeholder=
"brak"
type=
"number"
readonly=
"readonly"
value=
"${product.productId}"
/></td>
</tr>
<tr>
<td><label
for=
"productName"
>
Nazwa towaru:
</label></td>
<td><input
name=
"productName"
placeholder=
"nazwa..."
type=
"text"
value=
"${product.productName}"
/>
</td>
</tr>
<tr>
<td><label
for=
"price"
>
Cena:
</label></td>
<td><input
name=
"price"
placeholder=
"12.90"
title=
"tu wpisz cenę"
type=
"number"
step=
"0.01"
value=
"${product.price}"
/>
</td>
</tr>
<tr>
<td><label
for=
"vat"
>
Stawka VAT:
</label></td>
<td><input
name=
"vat"
placeholder=
"0.23"
title=
"tu wpisz vat"
type=
"number"
step=
"0.01"
value=
"${product.vat}"
/>
</td>
</tr>
<tr>
<td><label
for=
"description"
>
Opis:
</label></td>
<td><textarea
name=
"description"
rows=
"10"
cols=
"120"
>
${product.description}
</textarea></td>
</tr>
<tr>
<td><button>
Zapisz
</button></td>
</tr>
</table>
</form>
<div
class=
"action"
><a
href=
"products9.jsp"
>
powrót do listy produktów
</a></div>
<div
class=
"action"
><a
href=
"index.html"
>
powrót do spisu treści
</a></div>
</body>
</html>
PC39-Wielomodulowy/sklep_web/src/main/webapp/products3.jsp
0 → 100644
View file @
85ce2d12
<
%@
page
import=
"sklep.model.Product"
%
>
<
%@
page
import=
"java.util.List"
%
>
<
%@
page
import=
"sklep.db.ProductDAO"
%
>
<
%@
page
import=
"sklep.db.DBConnection"
%
>
<
%@
page
language=
"java"
contentType=
"text/html; charset=UTF-8"
pageEncoding=
"UTF-8"
%
>
<!DOCTYPE html>
<html>
<head>
<meta
charset=
"UTF-8"
>
<title>
Lista produktów 3
</title>
</head>
<body>
<h1>
Lista produktów - wersja 3 JSP
</h1>
<p>
W tej wersji wewnątrz skryptu JSP umieścimy fragmenty Javy, tzw. scriptlets.
To jest pierwsza techniczna możliwość, którą oferował standard JSP.
</p>
<p>
Uwaga - ta wersja nadal jest nieporządna i
<strong>
nie jest
</strong>
wzorem do naśladowania.
Mieszanie kodu HTML z Javą w taki sposób, szczególnie jak zrobiliśmy z pętlą pod koniec, jest w bardzo złym stylu.
</p>
<p>
[
<a
href=
"index.html"
>
powrót do spisu treści
</a>
]
</p>
<
%
--
Poni
ż
ej
skryptlet
,
kt
ó
ry
otwiera
po
łą
czenie
z
baz
ą
danych:
--
%
>
<
%
DBConnection
db =
DBConnection.open();
ProductDAO
dao =
db.productDAO();
%
>
<p>
Pobieranie danych...
</p>
<
%
List
<
Product
>
products = dao.readAll();
%>
<p>
Pobrano
<
%=
products
.
size
()
%
>
produktów.
</p>
<h3>
Wszystkie produkty
</h3>
<ul>
<
%
for
(
Product
product
:
products
)
{
%
>
<li><
%=
product
.
getProductName
()
%
>
za
<
%=
product
.
getPrice
()
%
></li>
<
%
}
%
>
</ul>
<
%
db
.
close
();
%
>
<p>
[
<a
href=
"index.html"
>
powrót do spisu treści
</a>
]
</p>
</body>
</html>
PC39-Wielomodulowy/sklep_web/src/main/webapp/products4.jsp
0 → 100644
View file @
85ce2d12
<
%@
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>
PC39-Wielomodulowy/sklep_web/src/main/webapp/products5.jsp
0 → 100644
View file @
85ce2d12
<
%@
page
language=
"java"
contentType=
"text/html; charset=UTF-8"
pageEncoding=
"UTF-8"
%
>
<
%@
taglib
prefix=
"c"
uri=
"http://java.sun.com/jsp/jstl/core"
%
>
<!DOCTYPE html>
<html>
<head>
<meta
charset=
"UTF-8"
>
<title>
Lista produktów 5
</title>
<link
rel=
"stylesheet"
type=
"text/css"
href=
"styl.css"
>
</head>
<body>
<h1>
Lista produktów - wersja 5 JSP
</h1>
<jsp:useBean
id=
"productBean"
class=
"sklep.web.ProductBean"
/>
<c:forEach
var=
"p"
items=
"${productBean.allProducts}"
>
<div
class=
"product"
>
<h3>
${p.productName}
</h3>
<div
class=
"price"
>
Cena: ${p.price}
</div>
<div
class=
"price"
>
VAT ${p.vat * 100}%
</div>
<c:if
test=
"${not empty p.description}"
>
<p>
${p.description}
</p>
</c:if>
</div>
</c:forEach>
</body>
</html>
PC39-Wielomodulowy/sklep_web/src/main/webapp/products6.jsp
0 → 100644
View file @
85ce2d12
<
%@
page
language=
"java"
contentType=
"text/html; charset=UTF-8"
pageEncoding=
"UTF-8"
%
>
<
%@
taglib
prefix=
"c"
uri=
"http://java.sun.com/jsp/jstl/core"
%
>
<!DOCTYPE html>
<html>
<head>
<meta
charset=
"UTF-8"
>
<title>
Lista produktów 6
</title>
<link
rel=
"stylesheet"
type=
"text/css"
href=
"styl.css"
>
</head>
<body>
<h1>
Lista produktów - wersja 6 JSP z filtrem
</h1>
<jsp:useBean
id=
"productBean"
class=
"sklep.web.ProductBean"
/>
<form
id=
"wyszukiwarka"
method=
"get"
>
<h2>
Filtr cen
</h2>
<table
class=
"formularz"
>
<tr><td><label
for=
"min_price"
>
Cena minimalna:
</label></td>
<td><input
type=
"number"
name=
"min_price"
value=
"${param.min_price}"
></td></tr>
<tr><td><label
for=
"max_price"
>
Cena maksymalna:
</label></td>
<td><input
type=
"number"
name=
"max_price"
value=
"${param.max_price}"
></td></tr>
<tr><td><button>
Szukaj
</button></td></tr>
</table>
</form>
<jsp:setProperty
name=
"productBean"
property=
"minPrice"
param=
"min_price"
/>
<jsp:setProperty
name=
"productBean"
property=
"maxPrice"
param=
"max_price"
/>
<c:forEach
var=
"p"
items=
"${productBean.filteredProducts}"
>
<div
class=
"product"
>
<h3>
${p.productName}
</h3>
<div
class=
"price"
>
Cena: ${p.price}
</div>
<div
class=
"price"
>
VAT ${p.vat * 100}%
</div>
<c:if
test=
"${not empty p.description}"
>
<p>
${p.description}
</p>
</c:if>
</div>
</c:forEach>
</body>
</html>
PC39-Wielomodulowy/sklep_web/src/main/webapp/products7.jsp
0 → 100644
View file @
85ce2d12
<
%@
page
language=
"java"
contentType=
"text/html; charset=UTF-8"
pageEncoding=
"UTF-8"
%
>
<
%@
taglib
prefix=
"c"
uri=
"http://java.sun.com/jsp/jstl/core"
%
>
<!DOCTYPE html>
<html>
<head>
<meta
charset=
"UTF-8"
>
<title>
Lista produktów 7
</title>
<link
rel=
"stylesheet"
type=
"text/css"
href=
"styl.css"
>
</head>
<body>
<h1>
Lista produktów - wersja 7
</h1>
<jsp:useBean
id=
"bean"
class=
"sklep.web.ProductBean"
/>
<form
id=
"wyszukiwarka"
method=
"get"
>
<h2>
Filtr cen
</h2>
<table
class=
"formularz"
>
<tr><td><label
for=
"min_price"
>
Cena minimalna:
</label></td>
<td><input
type=
"number"
name=
"min_price"
value=
"${param.min_price}"
></td></tr>
<tr><td><label
for=
"max_price"
>
Cena maksymalna:
</label></td>
<td><input
type=
"number"
name=
"max_price"
value=
"${param.max_price}"
></td></tr>
<tr><td><button>
Szukaj
</button></td></tr>
</table>
</form>
<div>
Produkty o cenach
<c:if
test=
"${not empty(param.min_price)}"
>
od ${param.min_price}
</c:if>
<c:if
test=
"${not empty(param.max_price)}"
>
do ${param.max_price}
</c:if>
</div>
<jsp:setProperty
name=
"bean"
property=
"minPrice"
param=
"min_price"
/>
<jsp:setProperty
name=
"bean"
property=
"maxPrice"
param=
"max_price"
/>
<c:forEach
var=
"p"
items=
"${bean.filteredProducts}"
>
<div
class=
"product"
>
<img
class=
"photo"
src=
"photo?productId=${p.productId}"
alt=
""
/>
<h3>
${p.productName}
</h3>
<div
class=
"price"
>
Cena: ${p.price}
</div>
<div
class=
"price"
>
VAT ${p.vat * 100}%
</div>
<c:if
test=
"${not empty p.description}"
>
<p>
${p.description}
</p>
</c:if>
</div>
</c:forEach>
</body>
</html>
PC39-Wielomodulowy/sklep_web/src/main/webapp/products8.jsp
0 → 100644
View file @
85ce2d12
<
%@
page
language=
"java"
contentType=
"text/html; charset=UTF-8"
pageEncoding=
"UTF-8"
%
>
<
%@
taglib
prefix=
"c"
uri=
"http://java.sun.com/jsp/jstl/core"
%
>
<!DOCTYPE html>
<html>
<head>
<meta
charset=
"UTF-8"
>
<title>
Lista produktów 8
</title>
<link
rel=
"stylesheet"
type=
"text/css"
href=
"styl.css"
>
</head>
<body>
<h1>
Lista produktów - wersja 8
</h1>
<jsp:useBean
id=
"bean"
class=
"sklep.web.ProductBean"
/>
<div
class=
"koszyk"
>
<h4>
Koszyk
</h4>
<ul>
<
%
--
Zauwa
ż
my
,
ż
e
dla
obiektu
koszyk
nie
wykonujemy
ju
ż
useBean
.
Po
prostu
zak
ł
adamy
,
ż
e
jest
obecny
(
w
sesji
).
Gdyby
go
nie
by
ł
o
,
to
p
ę
tla
si
ę
nie
wykona
.
--
%
>
<c:forEach
var=
"elm"
items=
"${basket.elements}"
>
<li>
${elm.productName} (${elm.quantity}) za
<b>
${elm.value}
</b></li>
</c:forEach>
</ul>
<p
class=
"total"
>
Do zapłaty: ${basket.totalValue}
</p>
</div>
<form
id=
"wyszukiwarka"
method=
"get"
>
<h2>
Filtr cen
</h2>
<table
class=
"formularz"
>
<tr><td><label
for=
"min_price"
>
Cena minimalna:
</label></td>
<td><input
type=
"number"
name=
"min_price"
value=
"${param.min_price}"
></td></tr>
<tr><td><label
for=
"max_price"
>
Cena maksymalna:
</label></td>
<td><input
type=
"number"
name=
"max_price"
value=
"${param.max_price}"
></td></tr>
<tr><td><button>
Szukaj
</button></td></tr>
</table>
</form>
<div>
Produkty o cenach
<c:if
test=
"${not empty(param.min_price)}"
>
od ${param.min_price}
</c:if>
<c:if
test=
"${not empty(param.max_price)}"
>
do ${param.max_price}
</c:if>
</div>
<jsp:setProperty
name=
"bean"
property=
"minPrice"
param=
"min_price"
/>
<jsp:setProperty
name=
"bean"
property=
"maxPrice"
param=
"max_price"
/>
<c:forEach
var=
"p"
items=
"${bean.filteredProducts}"
>
<div
class=
"product"
>
<img
class=
"photo"
src=
"photo?productId=${p.productId}"
alt=
""
/>
<h3>
${p.productName}
</h3>
<div
class=
"price"
>
Cena: ${p.price}
</div>
<div
class=
"price"
>
VAT ${p.vat * 100}%
</div>
<c:if
test=
"${not empty p.description}"
>
<p>
${p.description}
</p>
</c:if>
<div><a
href=
"add_to_basket?productId=${p.productId}"
>
dodaj do koszyka
</a></div>
</div>
</c:forEach>
</body>
</html>
PC39-Wielomodulowy/sklep_web/src/main/webapp/products9.jsp
0 → 100644
View file @
85ce2d12
<
%@
page
language=
"java"
contentType=
"text/html; charset=UTF-8"
pageEncoding=
"UTF-8"
%
>
<
%@
taglib
prefix=
"c"
uri=
"http://java.sun.com/jsp/jstl/core"
%
>
<!DOCTYPE html>
<html>
<head>
<meta
charset=
"UTF-8"
>
<title>
Lista produktów 9
</title>
<link
rel=
"stylesheet"
type=
"text/css"
href=
"styl.css"
>
</head>
<body>
<h1>
Lista produktów - wersja 9
</h1>
<jsp:useBean
id=
"bean"
class=
"sklep.web.ProductBean"
/>
<div
class=
"koszyk"
>
<h4>
Koszyk
</h4>
<ul>
<
%
--
Zauwa
ż
my
,
ż
e
dla
obiektu
koszyk
nie
wykonujemy
ju
ż
useBean
.
Po
prostu
zak
ł
adamy
,
ż
e
jest
obecny
(
w
sesji
).
Gdyby
go
nie
by
ł
o
,
to
p
ę
tla
si
ę
nie
wykona
.
--
%
>
<c:forEach
var=
"elm"
items=
"${basket.elements}"
>
<li>
${elm.productName} (${elm.quantity}) za
<b>
${elm.value}
</b></li>
</c:forEach>
</ul>
<p
class=
"total"
>
Do zapłaty: ${basket.totalValue}
</p>
</div>
<form
id=
"wyszukiwarka"
method=
"get"
>
<h2>
Filtr cen
</h2>
<table
class=
"formularz"
>
<tr><td><label
for=
"min_price"
>
Cena minimalna:
</label></td>
<td><input
type=
"number"
name=
"min_price"
value=
"${param.min_price}"
></td></tr>
<tr><td><label
for=
"max_price"
>
Cena maksymalna:
</label></td>
<td><input
type=
"number"
name=
"max_price"
value=
"${param.max_price}"
></td></tr>
<tr><td><button>
Szukaj
</button></td></tr>
</table>
</form>
<div>
Produkty o cenach
<c:if
test=
"${not empty(param.min_price)}"
>
od ${param.min_price}
</c:if>
<c:if
test=
"${not empty(param.max_price)}"
>
do ${param.max_price}
</c:if>
</div>
<jsp:setProperty
name=
"bean"
property=
"minPrice"
param=
"min_price"
/>
<jsp:setProperty
name=
"bean"
property=
"maxPrice"
param=
"max_price"
/>
<c:forEach
var=
"p"
items=
"${bean.filteredProducts}"
>
<div
class=
"product"
>
<img
class=
"photo"
src=
"photo?productId=${p.productId}"
alt=
""
/>
<h3>
${p.productName}
</h3>
<div
class=
"price"
>
Cena: ${p.price}
</div>
<div
class=
"price"
>
VAT ${p.vat * 100}%
</div>
<c:if
test=
"${not empty p.description}"
>
<p>
${p.description}
</p>
</c:if>
<div
class=
"action"
><a
href=
"add_to_basket?productId=${p.productId}"
>
dodaj do koszyka
</a></div>
<div
class=
"action"
><a
href=
"edit_product?productId=${p.productId}"
>
edytuj
</a></div>
<div
class=
"action"
><a
href=
"upload_photo.jsp?productId=${p.productId}"
>
zmień zdjęcie
</a></div>
</div>
</c:forEach>
<div
class=
"action"
><a
href=
"edit_product"
>
Dodaj nowy produkt
</a></div>
</body>
</html>
PC39-Wielomodulowy/sklep_web/src/main/webapp/styl.css
0 → 100644
View file @
85ce2d12
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
;
}
PC39-Wielomodulowy/sklep_web/src/main/webapp/upload_photo.jsp
0 → 100644
View file @
85ce2d12
<
%@
page
language=
"java"
contentType=
"text/html; charset=UTF-8"
pageEncoding=
"UTF-8"
%
>
<
%@
taglib
prefix=
"c"
uri=
"http://java.sun.com/jsp/jstl/core"
%
>
<!DOCTYPE html>
<html>
<head>
<meta
charset=
"UTF-8"
>
<title>
Edycja zdjęcia
</title>
<link
rel=
"stylesheet"
type=
"text/css"
href=
"styl.css"
>
</head>
<body>
<h1>
Wgraj zdjęcie produktu
</h1>
<div>
Produkt nr
<strong>
${param.productId}
</strong></div>
<div>
Aktualne zdjęcie:
<br/>
<img
src=
"photo?productId=${param.productId}"
alt=
"Brak zdjęcia"
>
</div>
<
%
--
action
powoduje
,
ż
e
zapytanie
z
formularza
jest
wysy
ł
ane
pod
podany
adres
,
a
nie
bie
żą
cy
.
Aby
wys
ł
a
ć
zawarto
ść
pliku
(
a
nie
tylko
jego
nazw
ę),
nale
ż
y
ustawi
ć
enctype
jak
poni
ż
ej
.
Sam
plik
to
pole
formularza
typu
file
;
opr
ó
cz
niego
mog
ą
by
ć
inne
„
zwyk
ł
e
”
pola
.
Odpowiednio
trzeba
to
te
ż
obs
ł
u
ż
y
ć
w
serwlecie
-
patrz
klasa
DoUploadPhoto
.
--
%
>
<form
id=
"photo-form"
method=
"post"
action=
"doUploadPhoto"
enctype=
"multipart/form-data"
>
<input
type=
"hidden"
name=
"productId"
value=
"${param.productId}"
>
<label
for=
"plik"
>
Wybierz plik ze zdjęciem
</label>
<input
type=
"file"
name=
"plik"
accept=
"image/jpeg"
>
<br>
<button>
Wyślij
</button>
</form>
<p>
[
<a
href=
"products9.jsp"
>
powrót do listy produktów
</a>
]
</p>
<p>
[
<a
href=
"index.html"
>
powrót do spisu treści
</a>
]
</p>
</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