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
0ace79c3
Commit
0ace79c3
authored
Oct 17, 2023
by
Patryk Czarnik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rozmowa z formularzem
parent
1d509168
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
39 additions
and
0 deletions
+39
-0
Rozmowa.java
PC24-Serwlety/src/main/java/podstawy/Rozmowa.java
+38
-0
index.html
PC24-Serwlety/src/main/webapp/index.html
+1
-0
No files found.
PC24-Serwlety/src/main/java/podstawy/Rozmowa.java
0 → 100644
View file @
0ace79c3
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
(
"/rozmowa"
)
public
class
Rozmowa
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>Rozmowa z serwletem</h1>"
);
// w Javie 17 pojawiły się wieloliniowe Stringi, jak w Pythonie:
out
.
println
(
"""
<form>
<label for="
imie
">Jak na imię?</label>
<input id="
imie
" name="
imie
" type="
text
">
<button>Wyślij</button>
</form>
"""
);
// obsługa parametru
String
imie
=
request
.
getParameter
(
"imie"
);
out
.
println
(
"<div>Witaj "
+
imie
+
"</div>"
);
out
.
println
(
"</body></html>"
);
}
}
PC24-Serwlety/src/main/webapp/index.html
View file @
0ace79c3
...
@@ -9,6 +9,7 @@
...
@@ -9,6 +9,7 @@
<ul>
<ul>
<li><a
href=
"hello"
>
hello
</a>
- PierwszySerwlet
</li>
<li><a
href=
"hello"
>
hello
</a>
- PierwszySerwlet
</li>
<li><a
href=
"godzina"
>
która godzina
</a></li>
<li><a
href=
"godzina"
>
która godzina
</a></li>
<li><a
href=
"rozmowa"
>
rozmowa
</a>
- przykład formularza
</li>
</ul>
</ul>
</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