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
9ae1d6a1
Commit
9ae1d6a1
authored
Oct 17, 2023
by
Patryk Czarnik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
przyklad.jsp
parent
5b148e2f
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
49 additions
and
1 deletions
+49
-1
pom.xml
PC24-Serwlety/pom.xml
+1
-0
Kalkulator.java
PC24-Serwlety/src/main/java/podstawy/Kalkulator.java
+1
-1
index.html
PC24-Serwlety/src/main/webapp/index.html
+2
-0
przyklad.jsp
PC24-Serwlety/src/main/webapp/przyklad.jsp
+45
-0
No files found.
PC24-Serwlety/pom.xml
View file @
9ae1d6a1
...
@@ -23,6 +23,7 @@
...
@@ -23,6 +23,7 @@
</dependencies>
</dependencies>
<build>
<build>
<finalName>
${project.artifactId}
</finalName>
<plugins>
<plugins>
<plugin>
<plugin>
<groupId>
org.apache.maven.plugins
</groupId>
<groupId>
org.apache.maven.plugins
</groupId>
...
...
PC24-Serwlety/src/main/java/podstawy/Kalkulator.java
View file @
9ae1d6a1
...
@@ -11,7 +11,7 @@ import jakarta.servlet.http.HttpServletResponse;
...
@@ -11,7 +11,7 @@ import jakarta.servlet.http.HttpServletResponse;
@WebServlet
(
"/kalkulator"
)
@WebServlet
(
"/kalkulator"
)
public
class
Kalkulator
extends
HttpServlet
{
public
class
Kalkulator
extends
HttpServlet
{
@Override
@Override
protected
void
doGet
(
HttpServletRequest
request
,
HttpServletResponse
response
)
throws
ServletException
,
IOException
{
protected
void
doGet
(
HttpServletRequest
request
,
HttpServletResponse
response
)
throws
ServletException
,
IOException
{
response
.
setContentType
(
"text/html"
);
response
.
setContentType
(
"text/html"
);
...
...
PC24-Serwlety/src/main/webapp/index.html
View file @
9ae1d6a1
...
@@ -10,6 +10,8 @@
...
@@ -10,6 +10,8 @@
<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>
<li><a
href=
"rozmowa"
>
rozmowa
</a>
- przykład formularza
</li>
<li><a
href=
"kalkulator"
>
kalkulator
</a></li>
<li><a
href=
"przyklad.jsp"
>
przykład JSP
</a></li>
</ul>
</ul>
</body>
</body>
...
...
PC24-Serwlety/src/main/webapp/przyklad.jsp
0 → 100644
View file @
9ae1d6a1
<
%@
page
import=
"java.time.LocalTime"
%
>
<
%@
page
language=
"java"
contentType=
"text/html; charset=UTF-8"
pageEncoding=
"UTF-8"
%
>
<!DOCTYPE html>
<html>
<head>
<meta
charset=
"UTF-8"
>
<title>
Przykład JSP
</title>
</head>
<body>
<h1>
Przykładowe JSP
</h1>
<p>
Ala ma kota
</p>
<!-- To jest komentarz HTML - on będzie wysłany do klienta -->
<
%
--
To
jest
komentarz
w
JSP
.
Klient
tego
nie
zobaczy
--
%
>
<h2>
Skryptlety
</h2>
<
%
--
Fragmenty
HTML
i
zwyk
ł
ego
tekstu
pisane
w
JSP
s
ą
wysy
ł
ane
w
odpowiedzi
do
klienta
.
Ale
w
plikach
JSP
mo
ż
na
te
ż
umieszcza
ć
fragmenty
kodu
Java
wewn
ą
trz
tzw
.
scriptlets
.
--
%
>
<p>
Zaraz wykonam kod Javy:
</p>
<
%
out
.
println
("
Hej
,
tu
Java
wewn
ą
trz
JSP
");
System
.
out
.
println
("
a
kuku
");
int
x =
321;
%
>
<p>
Znowu tryb HTML
</p>
<
%
--
Istniej
ą
specjalne
wersje
skryptlet
ó
w
.
Powy
ż
ej
widzielismy
zwyk
ł
y
blok
kodu
.
Poni
ż
ej
zobaczymy
wstawienie
warto
ś
ci
do
outputu:
--
%
>
<p>
Wypisanie wyniku:
<
%=
2
*
x
%
></p>
<p>
Odczyt czasu:
<
%=
LocalTime
.
now
()
%
></p>
<
%!
static
int
licznik =
100;
String
dajGlos
()
{
return
"
hau
hau
";
}
%
>
<p>
Licznik:
<
%=
licznik
++
%
></p>
<p>
Metoda:
<
%=
dajGlos
()
%
></p>
<
%
--
Plik
JSP
jest
na
serwerze
t
ł
umaczony
na
klas
ę
serwletu
i
kompilowany
.
--
%
>
</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