언어/JSP

[JSP] 스크립틀릿, 표현식

Sime 2016. 10. 26. 12:41

jsp에서 import 하기( @ 를 사용 )
1
<%@page import="java.util.ArrayList" %> 
cs



기초 예제 소스

< jsp 파일 > 


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>테스트</title>
</head>
<body>
<!--     스크립틀릿 이라고 부르고 -->
<!--     자바코드를 실행할수 있는 영역 -->
    <%
        int num1 = 10;
        int num2 = 20;
        int add = num1 + num2;
    %>
    
<!--     표현식 이라고 부르고 자바메모리상의 데이터 변수나 상수를  -->
<!--     HTML값으로 뱉어주는 역할을 함 -->
    <%= num1 %> + <%= num2 %> = <%= add %>
</body>
</html>
cs



출력 

10 + 20 = 30




추가 사항


- 구조체 정의할때는 ! 를 달아 준다.


<%!
    class Loan {
        public int index;
        public int totalRepay;
        public int originRepay;
        public int interestRepay;
        public int remainAmount;
    }
%>


반응형