JSTLEx01.WebContent.gugudan
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1.0,minimum-scale=1.0,maximum-scale=1.0">
<title>Insert title here</title>
</head>
<body>
<table border="1" width="800">
<c:forEach var="row" begin="0" end="9">
<tr>
<c:forEach var="col" begin="0" end="9">
<c:choose>
<c:when test="${ row==0 && col==0 }">
<td></td>
</c:when>
<c:when test="${ row==0}">
<td> X ${ col }</td>
</c:when>
<c:when test="${ col==0}">
<td>${ row }단</td>
</c:when>
<c:otherwise>
<td>${ row } x ${ col } = ${ row * col }</td>
</c:otherwise>
</c:choose>
</c:forEach>
</tr>
</c:forEach>
</table>
</body>
</html>
JstlEx01.WebContent.jstlEx07 - forEach 태그
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<c:redirect url="https://www.daum.net" />
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<c:redirect url="https://search.daum.net/search?q=avengers"></c:redirect>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<c:redirect url="https://search.daum.net/search">
<c:param name="w" value="tot" />
<c:param name="q" value="avengers" />
</c:redirect>
JstlEx01.WebContent.jstlEx08
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1.0,minimum-scale=1.0,maximum-scale=1.0">
<title>Insert title here</title>
</head>
<body>
<c:url var="url1" value="./test1.do" />
<ul>
<li>url 1 = ${ url1 }</li>
</ul>
</body>
</html>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1.0,minimum-scale=1.0,maximum-scale=1.0">
<title>Insert title here</title>
</head>
<body>
<c:url var="url1" value="./test1.do" />
<c:url var="url2" value="./test1.do">
<c:param name="key1" value="data1" />
<c:param name="key2" value="data2" />
</c:url>
<ul>
<li>url 1 = ${ url1 }</li>
<li>url 2 = ${ url2 }</li>
</ul>
</body>
</html>
JstlEx01.WebContent.jstlEx09
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<c:url var="url" value="https://search.daum.net/search">
<c:param name="w" value="tot" />
<c:param name="q" value="고현정" />
</c:url>
${ url }<br />
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<c:url var="url" value="https://search.daum.net/search">
<c:param name="w" value="tot" />
<c:param name="q" value="고현정" />
</c:url>
<!-- ${ url } --><br />
<c:redirect url="${ url }" />
JstlEx01.WebContent.jstlEx10
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<c:import url="https://m.daum.net" />
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<c:import var="data" url="https://m.daum.net" />
<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1.0,minimum-scale=1.0,maximum-scale=1.0">
<title>Insert title here</title>
</head>
<body>
데이터 보이기 : <br />
<textarea rows="50" cols="50">
${ data }
</textarea>
</body>
</html>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<c:import var="data1" url="https://m.daum.net" />
<c:import var="data2" url="https://maps.googleapis.com/maps/api/geocode/json">
<c:param name="language" value="ko" />
<c:param name="address" value="경복궁"/>
</c:import>
<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1.0,minimum-scale=1.0,maximum-scale=1.0">
<title>Insert title here</title>
</head>
<body>
데이터 보이기 : <br />
<textarea rows="50" cols="50">
${ data2 }
</textarea>
</body>
</html>
JSTLEx02.WebContent.jstlEx01
SQL> select * from dept2;
select * from dept2
*
1행에 오류:
ORA-00942: 테이블 또는 뷰가 존재하지 않습니다
SQL> create table dept2 as select * from dept;
테이블이 생성되었습니다.
SQL> select * from dept2;
DEPTNO DNAME LOC
---------- ---------------------------- --------------------------
10 ACCOUNTING NEW YORK
20 RESEARCH DALLAS
30 SALES CHICAGO
40 OPERATIONS BOSTON
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="http://java.sun.com/jsp/jstl/sql" %> <!-- SQL 사용 -->
<s:setDataSource
url = "jdbc:oracle:thin:@localhost:1521:orcl"
driver = "oracle.jdbc.driver.OracleDriver"
user = "scott"
password = "tiger"
var = "ds" />
<s:update
dataSource = "${ ds }"
sql = "insert into dept2 values(91, '홍보', '서울')"></s:update>
에러 없이 실행 됨
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="http://java.sun.com/jsp/jstl/sql" %> <!-- SQL 사용 -->
<s:setDataSource
url = "jdbc:oracle:thin:@localhost:1521:orcl"
driver = "oracle.jdbc.driver.OracleDriver"
user = "scott"
password = "tiger"
var = "ds" />
<!-- <s:update
dataSource = "${ ds }"
sql = "insert into dept2 values(91, '홍보', '서울')"></s:update> -->
<s:update
dataSource = "${ ds }"
sql = "insert into dept2 values(?, ?, ?)">
<s:param value="97" />
<s:param value="홍보" />
<s:param value="대구" />
</s:update>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ taglib prefix="s" uri="http://java.sun.com/jsp/jstl/sql" %> <!-- SQL 사용 -->
<s:setDataSource
url = "jdbc:oracle:thin:@localhost:1521:orcl"
driver = "oracle.jdbc.driver.OracleDriver"
user = "scott"
password = "tiger"
var = "ds" />
<!-- <s:update
dataSource = "${ ds }"
sql = "insert into dept2 values(91, '홍보', '서울')"></s:update> -->
<!--<s:update
dataSource = "${ ds }"
sql = "insert into dept2 values(?, ?, ?)">
<s:param value="97" />
<s:param value="홍보" />
<s:param value="대구" />
</s:update>-->
<s:update
dataSource = "${ ds }">
insert into dept2 values(?, ?, ?)
<s:param value="97" />
<s:param value="홍보" />
<s:param value="울산" />
</s:update>
JSTLEx02.WebContent.jstlEx02
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="s" uri="http://java.sun.com/jsp/jstl/sql" %>
<s:setDataSource
url = "jdbc:oracle:thin:@localhost:1521:orcl"
driver = "oracle.jdbc.driver.OracleDriver"
user = "scott"
password = "tiger"
var = "ds" />
<s:query var="rs" dataSource="${ ds }">
select * from dept2
</s:query>
<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1.0,minimum-scale=1.0,maximum-scale=1.0">
<title>Insert title here</title>
</head>
<body>
<table border="1" width="800">
<tr>
<c:forEach var="cName" items="${ rs.columnNames }">
<td>${ cName }</td>
</c:forEach>
</tr>
</table>
</body>
</html>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="s" uri="http://java.sun.com/jsp/jstl/sql" %>
<s:setDataSource
url = "jdbc:oracle:thin:@localhost:1521:orcl"
driver = "oracle.jdbc.driver.OracleDriver"
user = "scott"
password = "tiger"
var = "ds" />
<s:query var="rs" dataSource="${ ds }">
select deptno as 부서번호, dname as 부서명, loc as 부서위치 from dept2
</s:query>
<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1.0,minimum-scale=1.0,maximum-scale=1.0">
<title>Insert title here</title>
</head>
<body>
<table border="1" width="800">
<tr>
<c:forEach var="cName" items="${ rs.columnNames }">
<td>${ cName }</td>
</c:forEach>
</tr>
</table>
</body>
</html>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="s" uri="http://java.sun.com/jsp/jstl/sql" %>
<s:setDataSource
url = "jdbc:oracle:thin:@localhost:1521:orcl"
driver = "oracle.jdbc.driver.OracleDriver"
user = "scott"
password = "tiger"
var = "ds" />
<s:query var="rs" dataSource="${ ds }">
select deptno, dname, loc from dept2
</s:query>
<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1.0,minimum-scale=1.0,maximum-scale=1.0">
<title>Insert title here</title>
</head>
<body>
<table border="1" width="800">
<tr>
<c:forEach var="cName" items="${ rs.columnNames }">
<td>${ cName }</td>
</c:forEach>
</tr>
<c:forEach var="data" items="${ rs.rows }">
<tr>
<td>${ data.deptno }</td>
<td>${ data.dname }</td>
<td>${ data.loc }</td>
</tr>
</c:forEach>
</table>
</body>
</html>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="s" uri="http://java.sun.com/jsp/jstl/sql" %>
<s:setDataSource
url = "jdbc:oracle:thin:@localhost:1521:orcl"
driver = "oracle.jdbc.driver.OracleDriver"
user = "scott"
password = "tiger"
var = "ds" />
<s:query var="rs" dataSource="${ ds }">
select deptno as 부서번호, dname as 부서명, loc as 부서위치 from dept2
</s:query>
<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1.0,minimum-scale=1.0,maximum-scale=1.0">
<title>Insert title here</title>
</head>
<body>
<table border="1" width="800">
<tr>
<c:forEach var="cName" items="${ rs.columnNames }">
<td>${ cName }</td>
</c:forEach>
</tr>
<c:forEach var="data" items="${ rs.rows }">
<tr>
<td>${ data["부서번호"] }</td>
<td>${ data["부서명"] }</td>
<td>${ data["부서위치"] }</td>
</tr>
</c:forEach>
</table>
</body>
</html>
JSTLEx03.WebContent.META-INF.context
<?xml version="1.0" encoding="utf-8" ?>
<Context>
<Resource
name="jdbc/oracle"
auth="Container"
type="javax.sql.DataSource"
driverClassName="oracle.jdbc.driver.OracleDriver"
url="jdbc:oracle:thin:@localhost:1521:orcl"
username="scott"
password="tiger"
maxTotal="20"
maxWaitMillis="5000"/>
</Context>
JSTLEx03.WebContent.jstlEx03
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="s" uri="http://java.sun.com/jsp/jstl/sql" %>
<s:setDataSource
dataSource="jdbc/oracle"
var = "ds" />
<s:query var="rs" dataSource="${ ds }">
select deptno as 부서번호, dname as 부서명, loc as 부서위치 from dept2
</s:query>
<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1.0,minimum-scale=1.0,maximum-scale=1.0">
<title>Insert title here</title>
</head>
<body>
<table border="1" width="800">
<tr>
<c:forEach var="cName" items="${ rs.columnNames }">
<td>${ cName }</td>
</c:forEach>
</tr>
<c:forEach var="data" items="${ rs.rows }">
<tr>
<td>${ data["부서번호"] }</td>
<td>${ data["부서명"] }</td>
<td>${ data["부서위치"] }</td>
</tr>
</c:forEach>
</table>
</body>
</html>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="s" uri="http://java.sun.com/jsp/jstl/sql" %>
<s:query var="rs" dataSource="jdbc/oracle">
select deptno as 부서번호, dname as 부서명, loc as 부서위치 from dept2
</s:query>
<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1.0,minimum-scale=1.0,maximum-scale=1.0">
<title>Insert title here</title>
</head>
<body>
<table border="1" width="800">
<tr>
<c:forEach var="cName" items="${ rs.columnNames }">
<td>${ cName }</td>
</c:forEach>
</tr>
<c:forEach var="data" items="${ rs.rows }">
<tr>
<td>${ data["부서번호"] }</td>
<td>${ data["부서명"] }</td>
<td>${ data["부서위치"] }</td>
</tr>
</c:forEach>
</table>
</body>
</html>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="s" uri="http://java.sun.com/jsp/jstl/sql" %>
<s:query
var="rs"
dataSource="jdbc/oracle"
maxRows="3"
startRow="3">
select deptno as 부서번호, dname as 부서명, loc as 부서위치 from dept2
</s:query>
<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1.0,minimum-scale=1.0,maximum-scale=1.0">
<title>Insert title here</title>
</head>
<body>
<table border="1" width="800">
<tr>
<c:forEach var="cName" items="${ rs.columnNames }">
<td>${ cName }</td>
</c:forEach>
</tr>
<c:forEach var="data" items="${ rs.rows }">
<tr>
<td>${ data["부서번호"] }</td>
<td>${ data["부서명"] }</td>
<td>${ data["부서위치"] }</td>
</tr>
</c:forEach>
</table>
</body>
</html>
JSTLEx02.WebContent.use_number_tag - <fmt:formatNumber> 태그
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1.0,minimum-scale=1.0,maximum-scale=1.0">
<title>Insert title here</title>
</head>
<body>
<c:set var="price" value="10000" />
<fmt:formatNumber value="${ price }" type="number" var="numberType" />
<br />
통화 : <fmt:formatNumber value="${ price }"
type="currency" currencySymbol="원" />
<br />
퍼센트 : <fmt:formatNumber value="${ price }"
type="percent" groupingUsed="false" />
<br />
숫자 : ${ numberType }
<br />
패턴 : <fmt:formatNumber value="${ price }" pattern="00000000.00" />
</body>
</html>
JSTLEx02.WebContent.use_date_tag - <fmt:formatDate> 태그
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1.0,minimum-scale=1.0,maximum-scale=1.0">
<title>Insert title here</title>
</head>
<body>
<c:set var="now" value="<%=new java.util.Date() %>" />
<fmt:formatDate value="${ now }" type="date"
dateStyle="full" /> <br />
<fmt:formatDate value="${ now }" type="date"
dateStyle="short" /> <br />
<fmt:formatDate value="${ now }" type="time" /> <br />
<fmt:formatDate value="${ now }" type="both"
dateStyle="full" timeStyle="full" /> <br />
<fmt:formatDate value="${ now }" pattern="z a h:mm" /> <br />
</body>
</html>
JSTLEx02.WebContent.jstlEx04 - 함수
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1.0,minimum-scale=1.0,maximum-scale=1.0">
<title>Insert title here</title>
</head>
<body>
<c:set var="str1" value="functions <태그>를 사용합니다." />
<c:set var="str2" value="사용" />
<c:set var="tokens" value="1,2,3,4,5,6,7,8" />
<c:set var="array" value="${ fn:split(token, ',') }" />
문자열 길이 : ${ fn:length(str1) }<br />
</body>
</html>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1.0,minimum-scale=1.0,maximum-scale=1.0">
<title>Insert title here</title>
</head>
<body>
<c:set var="str1" value="functions <태그>를 사용합니다." />
<c:set var="str2" value="사용" />
<c:set var="tokens" value="1,2,3,4,5,6,7,8" />
<c:set var="array" value="${ fn:split(token, ',') }" />
문자열 길이 : ${ fn:length(str1) }<br />
대소문자 :
${ fn:toLowerCase(str1) }<br />
${ fn:toUpperCase(str1) }<br />
</body>
</html>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1.0,minimum-scale=1.0,maximum-scale=1.0">
<title>Insert title here</title>
</head>
<body>
<c:set var="str1" value="functions <태그>를 사용합니다." />
<c:set var="str2" value="사용" />
<c:set var="tokens" value="1,2,3,4,5,6,7,8" />
<c:set var="array" value="${ fn:split(token, ',') }" />
문자열 길이 : ${ fn:length(str1) }<br />
대소문자 :
${ fn:toLowerCase(str1) }<br />
${ fn:toUpperCase(str1) }<br />
<br />
문자열 분리 : ${ fn:substring(str1, 3, 6) }<br />
</body>
</html>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1.0,minimum-scale=1.0,maximum-scale=1.0">
<title>Insert title here</title>
</head>
<body>
<c:set var="str1" value="functions <태그>를 사용합니다." />
<c:set var="str2" value="사용" />
<c:set var="tokens" value="1,2,3,4,5,6,7,8" />
<c:set var="array" value="${ fn:split(token, ',') }" />
문자열 길이 : ${ fn:length(str1) }<br />
대소문자 :
${ fn:toLowerCase(str1) }<br />
${ fn:toUpperCase(str1) }<br />
<br />
문자열 분리 : ${ fn:substring(str1, 3, 6) }<br />
문자열 치환 : ${ fn:replace(str1, " ", "-") }<br />
</body>
</html>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1.0,minimum-scale=1.0,maximum-scale=1.0">
<title>Insert title here</title>
</head>
<body>
<c:set var="str1" value="functions <태그>를 사용합니다." />
<c:set var="str2" value="사용" />
<c:set var="tokens" value="1,2,3,4,5,6,7,8" />
<c:set var="array" value="${ fn:split(token, ',') }" />
문자열 길이 : ${ fn:length(str1) }<br />
대소문자 :
${ fn:toLowerCase(str1) }<br />
${ fn:toUpperCase(str1) }<br />
<br />
문자열 분리 : ${ fn:substring(str1, 3, 6) }<br />
문자열 치환 : ${ fn:replace(str1, str2, "-") }<br />
</body>
</html>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1.0,minimum-scale=1.0,maximum-scale=1.0">
<title>Insert title here</title>
</head>
<body>
<c:set var="str1" value="functions <태그>를 사용합니다." />
<c:set var="str2" value="사용" />
<c:set var="tokens" value="1,2,3,4,5,6,7,8" />
<c:set var="array" value="${ fn:split(token, ',') }" />
문자열 길이 : ${ fn:length(str1) }<br />
대소문자 :
${ fn:toLowerCase(str1) }<br />
${ fn:toUpperCase(str1) }<br />
<br />
문자열 분리 : ${ fn:substring(str1, 3, 6) }<br />
문자열 치환 : ${ fn:replace(str1, str2, "-") }<br />
문자열 검색 : ${ fn:indexOf(str1, str2) }<br />
</body>
</html>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1.0,minimum-scale=1.0,maximum-scale=1.0">
<title>Insert title here</title>
</head>
<body>
<c:set var="str1" value="functions <태그>를 사용합니다." />
<c:set var="str2" value="사용" />
<c:set var="tokens" value="1,2,3,4,5,6,7,8" />
<c:set var="array" value="${ fn:split(token, ',') }" />
문자열 길이 : ${ fn:length(str1) }<br />
대소문자 :
${ fn:toLowerCase(str1) }<br />
${ fn:toUpperCase(str1) }<br />
<br />
문자열 분리 : ${ fn:substring(str1, 3, 6) }<br />
문자열 치환 : ${ fn:replace(str1, str2, "-") }<br />
문자열 검색 : ${ fn:indexOf(str1, str2) }<br />
${ fn:contains(str1, str2) }<br />
</body>
</html>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1.0,minimum-scale=1.0,maximum-scale=1.0">
<title>Insert title here</title>
</head>
<body>
<c:set var="str1" value="functions <태그>를 사용합니다." />
<c:set var="str2" value="사용" />
문자열 길이 : ${ fn:length(str1) }<br />
대소문자 :
${ fn:toLowerCase(str1) }<br />
${ fn:toUpperCase(str1) }<br />
<br />
문자열 분리 : ${ fn:substring(str1, 3, 6) }<br />
문자열 치환 : ${ fn:replace(str1, str2, "-") }<br />
문자열 위치검색 : ${ fn:indexOf(str1, str2) }<br />
${ fn:contains(str1, "test") }<br />
<c:set var="tokens" value="1,2,3,4,5,6,7,8" />
<c:set var="array" value="${ fn:split(tokens, ',') }" />
문자열 결합 : ${ fn:join(array, "-") }<br />
</body>
</html>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1.0,minimum-scale=1.0,maximum-scale=1.0">
<title>Insert title here</title>
</head>
<body>
<c:set var="str1" value="functions <태그>를 사용합니다." />
<c:set var="str2" value="사용" />
문자열 길이 : ${ fn:length(str1) }<br />
대소문자 :
${ fn:toLowerCase(str1) }<br />
${ fn:toUpperCase(str1) }<br />
<br />
문자열 분리 : ${ fn:substring(str1, 3, 6) }<br />
문자열 치환 : ${ fn:replace(str1, str2, "-") }<br />
문자열 위치검색 : ${ fn:indexOf(str1, str2) }<br />
${ fn:contains(str1, "test") }<br />
<c:set var="tokens" value="1,2,3,4,5,6,7,8" />
<c:set var="array" value="${ fn:split(tokens, ',') }" />
문자열 결합 : ${ fn:join(array, "-") }<br />
<c:set var="str3" value="<html><head></head></body>" />
태그 치환 : ${ fn:escapeXml(str3) }<br />
</body>
</html>
우편번호 검색 - html 버전
ZipcodeSearch.model1.ZipcodeDAO
package model1;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.sql.DataSource;
public class ZipcodeDAO {
private DataSource dataSource = null;
public ZipcodeDAO() {
// TODO Auto-generated constructor stub
try {
Context initCtx = new InitialContext();
Context envCtx = (Context)initCtx.lookup("java:comp/env");
this.dataSource = (DataSource)envCtx.lookup("jdbc/oracle");
} catch (NamingException e) {
// TODO Auto-generated catch block
System.out.println("[에러] : " + e.getMessage());
}
}
public void zipcode() {
}
public ArrayList<ZipcodeTO> zipcodeList(ZipcodeTO to) {
Connection conn = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
ArrayList<ZipcodeTO> lists = new ArrayList<>();
try {
conn = dataSource.getConnection();
String sql = "select zipcode, sido, gugun, dong, ri, bunji, seq from zipcode where dong like ?";
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, to.getDong() + "%");
rs = pstmt.executeQuery();
while(rs.next()) {
ZipcodeTO zto = new ZipcodeTO();
zto.setZipcode(rs.getString("zipcode"));
zto.setSido(rs.getString("sido"));
zto.setGugun(rs.getString("gugun"));
zto.setDong(rs.getString("dong"));
zto.setRi(rs.getString("ri") == null ? "" : rs.getString("ri"));
zto.setBunji(rs.getString("bunji") == null ? "" : rs.getString("bunji"));
zto.setSeq(rs.getString("seq"));
lists.add(zto);
}
} catch(SQLException e) {
System.out.println("[에러] " + e.getMessage());
} finally {
if(rs != null) try { rs.close(); } catch(SQLException e) {}
if(pstmt != null) try { pstmt.close(); } catch(SQLException e) {}
if(conn != null) try { conn.close(); } catch(SQLException e) {}
}
return lists;
}
}
ZipcodeSearch.model1.ZipcodeTO
package model1;
public class ZipcodeTO {
private String zipcode;
private String sido;
private String gugun;
private String dong;
private String ri;
private String bunji;
private String seq;
public String getZipcode() {
return zipcode;
}
public void setZipcode(String zipcode) {
this.zipcode = zipcode;
}
public String getSido() {
return sido;
}
public void setSido(String sido) {
this.sido = sido;
}
public String getGugun() {
return gugun;
}
public void setGugun(String gugun) {
this.gugun = gugun;
}
public String getDong() {
return dong;
}
public void setDong(String dong) {
this.dong = dong;
}
public String getRi() {
return ri;
}
public void setRi(String ri) {
this.ri = ri;
}
public String getBunji() {
return bunji;
}
public void setBunji(String bunji) {
this.bunji = bunji;
}
public String getSeq() {
return seq;
}
public void setSeq(String seq) {
this.seq = seq;
}
}
ZipcodeSearch.model2.Action
package model2;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public interface Action {
public abstract void execute(HttpServletRequest request, HttpServletResponse response);
}
ZipcodeSearch.model2.ZipcodeAction
package model2;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class ZipcodeAction implements Action {
@Override
public void execute(HttpServletRequest request, HttpServletResponse response) {
// TODO Auto-generated method stub
}
}
ZipcodeSearch.model2.ZipcodeOkAction
package model2;
import java.util.ArrayList;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import model1.ZipcodeDAO;
import model1.ZipcodeTO;
public class ZipcodeOkAction implements Action {
@Override
public void execute(HttpServletRequest request, HttpServletResponse response) {
// TODO Auto-generated method stub
String dong = request.getParameter("dong").trim();
ZipcodeTO to = new ZipcodeTO();
to.setDong(dong);
ZipcodeDAO dao = new ZipcodeDAO();
ArrayList<ZipcodeTO> lists = dao.zipcodeList(to);
request.setAttribute("lists", lists);
}
}
ZipcodeSearch.servlet.ZipcodeController
package servlet;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import model2.Action;
import model2.ZipcodeAction;
import model2.ZipcodeOkAction;
/**
* Servlet implementation class ZipcodeController
*/
@WebServlet("*.do")
public class ZipcodeController extends HttpServlet {
private static final long serialVersionUID = 1L;
/**
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
*/
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
doProcess(request, response);
}
/**
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
*/
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
doProcess(request, response);
}
protected void doProcess(HttpServletRequest request, HttpServletResponse response) {
// TODO Auto-generated method stub
try {
request.setCharacterEncoding("utf-8");
String path = request.getRequestURI().replaceAll(request.getContextPath(), "");
String url = "/model2/error.jsp";
Action baction = null;
if(path.equals("/*.do") || path.equals("/zipcode.do")) {
baction = new ZipcodeAction();
baction.execute(request, response);
url = "/model2/zipcode.jsp";
} else if(path.equals("/zipcode_ok1.do")) {
baction = new ZipcodeOkAction();
baction.execute(request, response);
url = "/model2/zipcode_ok1.jsp";
}
RequestDispatcher dispatcher = request.getRequestDispatcher(url);
dispatcher.forward(request, response);
} catch (UnsupportedEncodingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (ServletException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
ZipcodeSearch.WebContent.META-INF.context
<?xml version="1.0" encoding="utf-8" ?>
<Context>
<Resource
name="jdbc/oracle"
auth="Container"
type="javax.sql.DataSource"
driverClassName="oracle.jdbc.driver.OracleDriver"
url="jdbc:oracle:thin:@localhost:1521:orcl"
username="scott"
password="tiger"
maxTotal="20"
maxWaitMillis="5000"/>
</Context>
ZipcodeSearch.WebContent.zipcode
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1.0,minimum-scale=1.0,maximum-scale=1.0">
<title>Insert title here</title>
</head>
<body>
<form action="./zipcode_ok1.do" method="post">
동이름 : <input type="text" name="dong" size="25" maxlength="3" />
<input type="submit" value="우편번호 검사" />
</form>
</body>
</html>
ZipcodeSearch.WebContent.zipcode_ok1
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ page import="java.util.ArrayList"%>
<%@ page import="model1.ZipcodeTO"%>
<%
ArrayList<ZipcodeTO> lists = (ArrayList)request.getAttribute("lists");
%>
<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1.0,minimum-scale=1.0,maximum-scale=1.0">
<title>Insert title here</title>
</head>
<body>
<table border="1" width="800">
<%
for(ZipcodeTO to : lists) {
out.println("<tr>");
out.println(" <td>" + to.getZipcode() + "</td>");
out.println(" <td>" + to.getSido() + "</td>");
out.println(" <td>" + to.getGugun() + "</td>");
out.println(" <td>" + to.getDong() + "</td>");
out.println(" <td>" + to.getRi() + "</td>");
out.println(" <td>" + to.getBunji() + "</td>");
out.println("</tr>");
}
%>
</table>
</body>
</html>
ZipcodeSearch.WebContent.Zipcode_ok1
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ page import="java.util.ArrayList"%>
<%@ page import="model1.ZipcodeTO"%>
<%
ArrayList<ZipcodeTO> lists = (ArrayList)request.getAttribute("lists");
%>
<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1.0,minimum-scale=1.0,maximum-scale=1.0">
<title>Insert title here</title>
</head>
<body>
<table border="1" width="800">
<%
for(ZipcodeTO to : lists) {
out.println("<tr>");
out.println(" <td>" + to.getZipcode() + "</td>");
out.println(" <td>" + to.getSido() + "</td>");
out.println(" <td>" + to.getGugun() + "</td>");
out.println(" <td>" + to.getDong() + "</td>");
out.println(" <td>" + to.getRi() + "</td>");
out.println(" <td>" + to.getBunji() + "</td>");
out.println("</tr>");
}
%>
</table>
</body>
</html>
우편번호 검색 - xml 버전
ZipcodeSearch.servlet.ZipcodeController
package servlet;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import model2.Action;
import model2.ZipcodeAction;
import model2.ZipcodeOkAction;
/**
* Servlet implementation class ZipcodeController
*/
@WebServlet("*.do")
public class ZipcodeController extends HttpServlet {
private static final long serialVersionUID = 1L;
/**
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
*/
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
doProcess(request, response);
}
/**
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
*/
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
doProcess(request, response);
}
protected void doProcess(HttpServletRequest request, HttpServletResponse response) {
// TODO Auto-generated method stub
try {
request.setCharacterEncoding("utf-8");
String path = request.getRequestURI().replaceAll(request.getContextPath(), "");
String url = "/model2/error.jsp";
Action baction = null;
if(path.equals("/*.do") || path.equals("/zipcode.do")) {
baction = new ZipcodeAction();
baction.execute(request, response);
url = "/model2/zipcode.jsp";
} else if(path.equals("/zipcode_ok1.do")) {
baction = new ZipcodeOkAction();
baction.execute(request, response);
url = "/model2/zipcode_ok1.jsp";
} else if(path.equals("/zipcode_xml.do")) {
baction = new ZipcodeOkAction();
baction.execute(request, response);
url = "/model2/zipcode_xml.jsp";
}
RequestDispatcher dispatcher = request.getRequestDispatcher(url);
dispatcher.forward(request, response);
} catch (UnsupportedEncodingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (ServletException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
ZipcodeSearch.WebContent.zipcode
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1.0,minimum-scale=1.0,maximum-scale=1.0">
<title>Insert title here</title>
</head>
<body>
<form action="./zipcode_xml.do" method="post">
동이름 : <input type="text" name="dong" size="25" maxlength="3" />
<input type="submit" value="우편번호 검사" />
</form>
</body>
</html>
ZipcodeSearch.WebContent.Zipcode_xml
<%@ page language="java" contentType="text/xml; charset=UTF-8"
pageEncoding="UTF-8" trimDirectiveWhitespaces="true"%>
<%@ page import="java.util.ArrayList"%>
<%@ page import="model1.ZipcodeTO"%>
<%
ArrayList<ZipcodeTO> lists = (ArrayList)request.getAttribute("lists");
out.println("<addresses>");
for(ZipcodeTO to : lists) {
out.println("<address>");
out.println(" <zipcode>" + to.getZipcode() + "</zipcode>");
out.println(" <sido>" + to.getSido() + "</sido>");
out.println(" <gugun>" + to.getGugun() + "</gugun>");
out.println(" <dong>" + to.getDong() + "</dong>");
out.println(" <ri>" + to.getRi() + "</ri>");
out.println(" <bunji>" + to.getBunji() + "</bunji>");
out.println("</address>");
}
out.println("</addresses>");
%>
우편번호 검색 - json 버전
ZipcodeSearch.servlet.ZipcodeController
package servlet;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import javax.servlet.RequestDispatcher;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import model2.Action;
import model2.ZipcodeAction;
import model2.ZipcodeOkAction;
/**
* Servlet implementation class ZipcodeController
*/
@WebServlet("*.do")
public class ZipcodeController extends HttpServlet {
private static final long serialVersionUID = 1L;
/**
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
*/
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
doProcess(request, response);
}
/**
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
*/
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
doProcess(request, response);
}
protected void doProcess(HttpServletRequest request, HttpServletResponse response) {
// TODO Auto-generated method stub
try {
request.setCharacterEncoding("utf-8");
String path = request.getRequestURI().replaceAll(request.getContextPath(), "");
String url = "/model2/error.jsp";
Action baction = null;
if(path.equals("/*.do") || path.equals("/zipcode.do")) {
baction = new ZipcodeAction();
baction.execute(request, response);
url = "/model2/zipcode.jsp";
} else if(path.equals("/zipcode_ok1.do")) {
baction = new ZipcodeOkAction();
baction.execute(request, response);
url = "/model2/zipcode_ok1.jsp";
} else if(path.equals("/zipcode_xml.do")) {
baction = new ZipcodeOkAction();
baction.execute(request, response);
url = "/model2/zipcode_xml.jsp";
} else if(path.equals("/zipcode_json.do")) {
baction = new ZipcodeOkAction();
baction.execute(request, response);
url = "/model2/zipcode_json.jsp";
}
RequestDispatcher dispatcher = request.getRequestDispatcher(url);
dispatcher.forward(request, response);
} catch (UnsupportedEncodingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (ServletException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
ZipcodeSearch.WebContent.zipcode
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html lang="ko">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1.0,minimum-scale=1.0,maximum-scale=1.0">
<title>Insert title here</title>
</head>
<body>
<!-- <form action="./zipcode_ok1.do" method="post">-->
<!-- <form action="./zipcode_xml.do" method="post">-->
<form action="./zipcode_json.do" method="post">
동이름 : <input type="text" name="dong" size="25" maxlength="3" />
<input type="submit" value="우편번호 검사" />
</form>
</body>
</html>
ZipcodeSearch.WebContent.Zipcode_json
<%@ page language="java" contentType="text/plain; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ page import="java.util.ArrayList"%>
<%@ page import="model1.ZipcodeTO"%>
<%
ArrayList<ZipcodeTO> lists = (ArrayList)request.getAttribute("lists");
out.println("[");
//for(ZipcodeTO to : lists) {
for(int i=0; i<lists.size(); i++) {
ZipcodeTO to = lists.get(i);
out.println("{");
//"seq":"값",
out.println("\"zipcode\" : \"" + to.getZipcode() + "\",");
out.println("\"sido\" : \"" + to.getSido() + "\",");
out.println("\"gugun\" : \"" + to.getGugun() + "\",");
out.println("\"dong\" : \"" + to.getDong() + "\",");
out.println("\"ri\" : \"" + to.getRi() + "\",");
out.println("\"bunji\" : \"" + to.getBunji() + "\"");
out.println("}");
if(i != lists.size()-1) out.println(",");
}
out.println("]");
%>
'Web & Mobile > JSP' 카테고리의 다른 글
Lecture 62 - JSP(20) MyBatis 이용한 게시판, 사진이 나오는 앨범 게시판 (0) | 2019.06.14 |
---|---|
Lecture 61 - JSP(19) ZipcodeController, MyBatis 설정법, Mapper (0) | 2019.06.13 |
Lecture 59 - JSP(17) EL, <%= %>, EL을 Model1 게시판에 적용, JSTL (0) | 2019.06.11 |
Lecture 58 - JSP(16) Mail, Authentication, MyAuth, MailSender (0) | 2019.06.10 |
Lecture 57 - JSP(15) MVC Model2 기반 게시판(2) (0) | 2019.06.05 |
댓글