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
71450a96
Commit
71450a96
authored
Sep 28, 2022
by
Patryk Czarnik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
serwlet w oparciu o DAO
parent
01641dd7
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
40 additions
and
0 deletions
+40
-0
Products1.java
PC26-SklepWeb/src/main/java/sklep/web/Products1.java
+40
-0
No files found.
PC26-SklepWeb/src/main/java/sklep/web/Products1.java
0 → 100644
View file @
71450a96
package
sklep
.
web
;
import
java.io.IOException
;
import
java.io.PrintWriter
;
import
java.util.List
;
import
javax.servlet.ServletException
;
import
javax.servlet.annotation.WebServlet
;
import
javax.servlet.http.HttpServlet
;
import
javax.servlet.http.HttpServletRequest
;
import
javax.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
);
}
}
}
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