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
2c15d16b
Commit
2c15d16b
authored
Oct 17, 2023
by
Patryk Czarnik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
kalkulator - samo dodawanie
parent
0ace79c3
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
51 additions
and
1 deletions
+51
-1
Kalkulator.java
PC24-Serwlety/src/main/java/podstawy/Kalkulator.java
+49
-0
Rozmowa.java
PC24-Serwlety/src/main/java/podstawy/Rozmowa.java
+2
-1
No files found.
PC24-Serwlety/src/main/java/podstawy/Kalkulator.java
0 → 100644
View file @
2c15d16b
package
podstawy
;
import
java.io.IOException
;
import
java.io.PrintWriter
;
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
(
"/kalkulator"
)
public
class
Kalkulator
extends
HttpServlet
{
@Override
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><body>"
);
out
.
println
(
"<h1>Kalkulator</h1>"
);
out
.
println
(
"""
<form>
<input name="
liczba1
" type="
text
">
<select name="
operacja
">
<option value='+'>+</option>
<option value='-'>-</option>
<option value='*'>*</option>
<option value='/'>/</option>
</select>
<input name="
liczba2
" type="
text
">
<br/>
<button>Oblicz</button>
</form>
"""
);
String
arg1
=
request
.
getParameter
(
"liczba1"
);
String
arg2
=
request
.
getParameter
(
"liczba2"
);
if
(
arg1
!=
null
&&
arg2
!=
null
)
{
int
liczba1
=
Integer
.
parseInt
(
arg1
);
int
liczba2
=
Integer
.
parseInt
(
arg2
);
int
wynik
=
liczba1
+
liczba2
;
out
.
print
(
"<div>Wynik: "
+
wynik
+
"</div>"
);
}
out
.
println
(
"</body></html>"
);
}
}
PC24-Serwlety/src/main/java/podstawy/Rozmowa.java
View file @
2c15d16b
...
...
@@ -30,8 +30,9 @@ public class Rozmowa extends HttpServlet {
"""
);
// obsługa parametru
String
imie
=
request
.
getParameter
(
"imie"
);
out
.
println
(
"<div>Witaj "
+
imie
+
"</div>"
);
out
.
println
(
"<div>Witaj "
+
imie
+
"</div>"
);
out
.
println
(
"</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