본문 바로가기

JAVA/JSP & Servlet

표준 액션(standard action) : 스크립팅 요소를 대신하는 표준액션

 

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

    pageEncoding="UTF-8"%>

 

<!DOCTYPE html>

<html>

<head>

<meta charset="UTF-8">

<title>표준액션 : 스크립팅 요소를 대신하는 표준액션</title>

</head>

<body>

 

        <jsp:scriptlet>

               String str1 = request.getParameter("num1");

               String str2 = request.getParameter("num2");

              

               int num1 = Integer.parseInt(str1);

               int num2 = Integer.parseInt(str2);

              

               int sum = add(num1, num2);

        </jsp:scriptlet>

 

        <jsp:expression>num1</jsp:expression> <jsp:expression>num2</jsp:expression> 합은 <jsp:expression>sum</jsp:expression> 입니다.

 

</body>

</html>

 

<jsp:declaration>

        private int add(int num1, int num2){

               return num1 + num2;

        }

</jsp:declaration>