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
8fe808df
Commit
8fe808df
authored
Apr 24, 2023
by
Patryk Czarnik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
koszyk w sesji
parent
1f255ec0
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
4 deletions
+7
-4
AddToBasket.java
PC25-SklepWeb/src/main/java/sklep/basket/AddToBasket.java
+6
-3
products8.jsp
PC25-SklepWeb/src/main/webapp/products8.jsp
+1
-1
No files found.
PC25-SklepWeb/src/main/java/sklep/basket/AddToBasket.java
View file @
8fe808df
...
@@ -7,6 +7,7 @@ import jakarta.servlet.annotation.WebServlet;
...
@@ -7,6 +7,7 @@ import jakarta.servlet.annotation.WebServlet;
import
jakarta.servlet.http.HttpServlet
;
import
jakarta.servlet.http.HttpServlet
;
import
jakarta.servlet.http.HttpServletRequest
;
import
jakarta.servlet.http.HttpServletRequest
;
import
jakarta.servlet.http.HttpServletResponse
;
import
jakarta.servlet.http.HttpServletResponse
;
import
jakarta.servlet.http.HttpSession
;
import
sklep.db.DBConnection
;
import
sklep.db.DBConnection
;
import
sklep.db.ProductDAO
;
import
sklep.db.ProductDAO
;
import
sklep.model.Product
;
import
sklep.model.Product
;
...
@@ -23,17 +24,19 @@ public class AddToBasket extends HttpServlet {
...
@@ -23,17 +24,19 @@ public class AddToBasket extends HttpServlet {
ProductDAO
productDAO
=
db
.
productDAO
();
ProductDAO
productDAO
=
db
.
productDAO
();
Product
product
=
productDAO
.
findById
(
productId
);
Product
product
=
productDAO
.
findById
(
productId
);
Basket
basket
=
(
Basket
)
getServletContext
().
getAttribute
(
"basket"
);
HttpSession
sesja
=
request
.
getSession
();
Basket
basket
=
(
Basket
)
sesja
.
getAttribute
(
"basket"
);
if
(
basket
==
null
)
{
if
(
basket
==
null
)
{
basket
=
new
Basket
();
basket
=
new
Basket
();
getServletContext
()
.
setAttribute
(
"basket"
,
basket
);
sesja
.
setAttribute
(
"basket"
,
basket
);
}
}
basket
.
addProduct
(
product
);
basket
.
addProduct
(
product
);
}
}
}
catch
(
Exception
e
)
{
}
catch
(
Exception
e
)
{
// ignorujemy błędy
// ignorujemy błędy
}
}
// Przekierowanie - każemy przeglądarce wejść pod ten adres.
response
.
sendRedirect
(
"products8.jsp"
);
}
}
}
}
PC25-SklepWeb/src/main/webapp/products8.jsp
View file @
8fe808df
...
@@ -5,7 +5,7 @@
...
@@ -5,7 +5,7 @@
<html>
<html>
<head>
<head>
<meta
charset=
"UTF-8"
>
<meta
charset=
"UTF-8"
>
<title>
Lista produktów
7
</title>
<title>
Lista produktów
8
</title>
<link
rel=
"stylesheet"
type=
"text/css"
href=
"styl.css"
>
<link
rel=
"stylesheet"
type=
"text/css"
href=
"styl.css"
>
</head>
</head>
<body>
<body>
...
...
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