Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
J
javab_20230617
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_20230617
Commits
23e021ad
Commit
23e021ad
authored
Jul 01, 2023
by
Patryk Czarnik
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Kalkulatory w wersji JSP
parent
20c9a318
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
113 additions
and
0 deletions
+113
-0
KalkulatorBean.java
...Servlety/src/main/java/serwlety/beans/KalkulatorBean.java
+41
-0
kalkulator_bean.jsp
PC23-Servlety/src/main/webapp/kalkulator_bean.jsp
+48
-0
mnozenie.jsp
PC23-Servlety/src/main/webapp/mnozenie.jsp
+24
-0
No files found.
PC23-Servlety/src/main/java/serwlety/beans/KalkulatorBean.java
0 → 100644
View file @
23e021ad
package
serwlety
.
beans
;
public
class
KalkulatorBean
{
private
int
arg1
,
arg2
;
private
String
operacja
;
public
int
getArg1
()
{
return
arg1
;
}
public
void
setArg1
(
int
arg1
)
{
this
.
arg1
=
arg1
;
}
public
int
getArg2
()
{
return
arg2
;
}
public
void
setArg2
(
int
arg2
)
{
this
.
arg2
=
arg2
;
}
public
String
getOperacja
()
{
return
operacja
;
}
public
void
setOperacja
(
String
operacja
)
{
this
.
operacja
=
operacja
;
}
public
int
getWynik
()
{
switch
(
operacja
)
{
case
"+"
:
return
arg1
+
arg2
;
case
"-"
:
return
arg1
-
arg2
;
case
"*"
:
return
arg1
*
arg2
;
case
"/"
:
return
arg1
/
arg2
;
default
:
return
0
;
}
}
}
PC23-Servlety/src/main/webapp/kalkulator_bean.jsp
0 → 100644
View file @
23e021ad
<
%@
page
language=
"java"
contentType=
"text/html; charset=UTF-8"
pageEncoding=
"UTF-8"
%
>
<
%@
taglib
prefix=
"c"
uri=
"jakarta.tags.core"
%
>
<!DOCTYPE html>
<html>
<head>
<meta
charset=
"UTF-8"
>
<title>
Kalkulator w JSP
</title>
<link
rel=
"stylesheet"
type=
"text/css"
href=
"styl.css"
>
</head>
<body>
<h1>
Kalkulator w JSP
</h1>
<form
class=
"kalkulator"
method=
"post"
>
<input
type=
"number"
name=
"arg1"
value=
"${param.arg1}"
>
<select
name=
"operacja"
>
<c:forEach
var=
"op"
items=
"+,-,*,/"
>
<c:choose>
<c:when
test=
"${op == param.operacja}"
>
<option
value=
"${op}"
selected=
"selected"
>
${op}
</option>
</c:when>
<c:otherwise>
<option
value=
"${op}"
>
${op}
</option>
</c:otherwise>
</c:choose>
</c:forEach>
</select>
<input
type=
"number"
name=
"arg2"
value=
"${param.arg2}"
>
<button
style=
"color:red;font-weight:bold"
>
Oblicz
</button>
</form>
<jsp:useBean
id=
"kalkulatorBean"
class=
"serwlety.beans.KalkulatorBean"
/>
<jsp:setProperty
name=
"kalkulatorBean"
property=
"arg1"
param=
"arg1"
/>
<jsp:setProperty
name=
"kalkulatorBean"
property=
"arg2"
param=
"arg2"
/>
<jsp:setProperty
name=
"kalkulatorBean"
property=
"operacja"
param=
"operacja"
/>
<c:if
test=
"${not empty param.operacja}"
>
<div
class=
"wynik"
>
${kalkulatorBean.arg1} ${kalkulatorBean.operacja} ${kalkulatorBean.arg2} =
<strong>
${kalkulatorBean.wynik}
</strong>
</div>
</c:if>
</body>
</html>
\ No newline at end of file
PC23-Servlety/src/main/webapp/mnozenie.jsp
0 → 100644
View file @
23e021ad
<
%@
page
contentType=
"text/html;charset=UTF-8"
language=
"java"
%
>
<
%@
taglib
prefix=
"c"
uri=
"jakarta.tags.core"
%
>
<html>
<head>
<title>
Mnożenie dwóch liczb
</title>
</head>
<body>
<h1>
Pomnóż dwie liczby
</h1>
<form>
<label
for=
"liczba1"
>
Pierwsza liczba:
</label>
<input
id=
"liczba1"
name=
"liczba1"
type=
"number"
>
<br/>
<label
for=
"liczba2"
>
Druga liczba:
</label>
<input
id=
"liczba2"
name=
"liczba2"
type=
"number"
>
<br/>
<button>
Pomnóż
</button>
</form>
<c:if
test=
"${not empty(param.liczba1) and not empty(param.liczba2)}"
>
<div>
${param.liczba1} × ${param.liczba2} =
<strong>
${param.liczba1 * param.liczba2}
</strong></div>
</c:if>
</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