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
2da4e062
Commit
2da4e062
authored
Apr 05, 2023
by
Patryk Czarnik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Styl CSS
parent
3031b2d1
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
44 additions
and
14 deletions
+44
-14
Kalkulator.java
PC24-Serwlety/src/main/java/formularze/Kalkulator.java
+2
-1
KalkulatorPost.java
PC24-Serwlety/src/main/java/formularze/KalkulatorPost.java
+6
-13
index.html
PC24-Serwlety/src/main/webapp/index.html
+1
-0
styl.css
PC24-Serwlety/src/main/webapp/styl.css
+35
-0
No files found.
PC24-Serwlety/src/main/java/formularze/Kalkulator.java
View file @
2da4e062
...
...
@@ -25,9 +25,10 @@ public class Kalkulator extends HttpServlet {
out
.
println
(
"<!DOCTYPE html>"
);
out
.
println
(
"<html><head>"
);
out
.
println
(
"<title>Kalkulator</title>"
);
out
.
println
(
"<link rel='stylesheet' type='text/css' href='styl.css'>"
);
out
.
println
(
"</head>"
);
out
.
println
(
"<body>"
);
out
.
println
(
"<form
style='border:2px solid green; padding: 1em; margin: 2em 0'
>"
);
out
.
println
(
"<form>"
);
out
.
println
(
"<input type='number' name='liczba1'>"
);
out
.
println
(
"<select name='operacja'>"
);
out
.
println
(
"<option value='+'>+</option>"
);
...
...
PC24-Serwlety/src/main/java/formularze/KalkulatorPost.java
View file @
2da4e062
...
...
@@ -15,17 +15,8 @@ public class KalkulatorPost extends HttpServlet {
@Override
protected
void
doGet
(
HttpServletRequest
request
,
HttpServletResponse
response
)
throws
ServletException
,
IOException
{
// w tej wersji GET służy tylko do wyświetlenia pustego formularza
response
.
setContentType
(
"text/html"
);
response
.
setCharacterEncoding
(
"UTF-8"
);
PrintWriter
out
=
response
.
getWriter
();
out
.
println
(
"<!DOCTYPE html>"
);
out
.
println
(
"<html><head>"
);
out
.
println
(
"<title>Kalkulator</title>"
);
out
.
println
(
"</head>"
);
out
.
println
(
"<body>"
);
PrintWriter
out
=
poczatekStrony
(
response
);
wydrukujFormularz
(
out
);
koniecStrony
(
out
);
}
...
...
@@ -43,10 +34,11 @@ public class KalkulatorPost extends HttpServlet {
int
liczba1
=
Integer
.
parseInt
(
parametr1
);
int
liczba2
=
Integer
.
parseInt
(
parametr2
);
int
wynik
=
oblicz
(
liczba1
,
liczba2
,
operacja
);
out
.
println
(
"<div>Działanie: "
+
liczba1
+
" "
+
operacja
+
" "
+
liczba2
+
"</div>"
);
out
.
println
(
"<div>Wynik: "
+
wynik
+
"</div>"
);
// out.println("<div class='wynik'>" + liczba1 + " " + operacja + " " + liczba2 + " = <strong>" + wynik + "<strong></div>");
out
.
printf
(
"<div class='wynik'>%s %s %s = <strong>%s</strong></div>\n"
,
liczba1
,
operacja
,
liczba2
,
wynik
);
}
catch
(
Exception
e
)
{
out
.
println
(
"<div>Błąd: "
+
e
+
"</div>"
);
out
.
println
(
"<div
class='error'
>Błąd: "
+
e
+
"</div>"
);
}
koniecStrony
(
out
);
...
...
@@ -65,6 +57,7 @@ public class KalkulatorPost extends HttpServlet {
out
.
println
(
"<!DOCTYPE html>"
);
out
.
println
(
"<html><head>"
);
out
.
println
(
"<title>Kalkulator</title>"
);
out
.
println
(
"<link rel='stylesheet' type='text/css' href='styl.css'>"
);
out
.
println
(
"</head>"
);
out
.
println
(
"<body>"
);
return
out
;
...
...
PC24-Serwlety/src/main/webapp/index.html
View file @
2da4e062
...
...
@@ -3,6 +3,7 @@
<head>
<meta
charset=
"UTF-8"
>
<title>
Spis treści
</title>
<link
rel=
'stylesheet'
type=
'text/css'
href=
'styl.css'
>
</head>
<body>
<h1>
Przykłady serwletów – spis treści
</h1>
...
...
PC24-Serwlety/src/main/webapp/styl.css
0 → 100644
View file @
2da4e062
body
{
background-color
:
#FFFFDD
;
}
h1
{
text-align
:
center
;
color
:
blue
;
}
form
{
width
:
600px
;
background-color
:
#AAEEFF
;
margin
:
2em
auto
;
padding
:
0.75em
;
border
:
4px
solid
blue
;
}
.wynik
{
width
:
600px
;
background-color
:
#CCFFDD
;
margin
:
2em
auto
;
padding
:
0.75em
;
border
:
4px
outset
green
;
}
.error
{
width
:
600px
;
background-color
:
white
;
color
:
red
;
margin
:
2em
auto
;
padding
:
0.75em
;
border
:
4px
double
red
;
}
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