본문 바로가기

JAVA/JSP & Servlet

익스프레션 언어(expression language) 산술, 비교, 논리, 조건 -param-

 

<%@ page language="java" contentType="text/html; charset=UTF-8"

    pageEncoding="UTF-8"%>

 

<!DOCTYPE html>

<html>

<head>

<meta charset="UTF-8">

<title>익스프레션 언어의 연산자</title>

</head>

<body>

 

<form action="OperatorResult.jsp" method="post">

 

num1 : <input type="text" name="num1"><br><br>

num2 : <input type="text" name="num2"><br><br>

<input type="submit" value="확인">

 

</form>

 

</body>

</html>

 

 

 

 

<%@ page language="java" contentType="text/html; charset=UTF-8"

    pageEncoding="UTF-8"%>

 

<!DOCTYPE html>

<html>

<head>

<meta charset="UTF-8">

<title>익스프레션 언어의 연산자</title>

</head>

<body>

 

X = ${param.num1}, Y= ${param.num2 } <br><br>

X + Y = ${param.num1 + param.num2 } <br>

X - Y = ${param.num1 - param.num2 } <br>

X * Y = ${param.num1 * param.num2 } <br>

X / Y = ${param.num1 / param.num2 } <br>

X % Y = ${param.num1 % param.num2 } <br><br>

 

X 큽니까? ${param.num1 - param.num2 > 0 }<br>

Y 큽니까? ${param.num1 - param.num2 < 0 }<br><br>

 

X Y 모두 양수입니까? ${(param.num1 > 0) && (param.num2 > 0) }<br><br>

 

X Y 같습니까? ${param.num1 == param.num2? "" : "아니오" }<br><br>

 

</body>

</html>