#db#database#custom
<dependencies>
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>
<dependency>
<groupId>com.oracle</groupId>
<artifactId>ojdbc6</artifactId>
<version>11.2.0.3</version>
</dependency>
</dependencies>
<%@ 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="sql" uri = "http://java.sun.com/jsp/jstl/sql" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
<sql:setDataSource var="db" driver="oracle.jdbc.driver.OracleDriver"
url="jdbc:oracle:thin:@localhost:1521/xe"
user="mydb"
password="1234" />
<sql:query dataSource="${db}" var="rs">
SELECT * FROM TBL_CODE
</sql:query>
<table>
<c:forEach var="obj" items="${rs.rows}">
<tr>
<td><c:out value="${obj.cd}"/></td>
<td><c:out value="${obj.nm}"/></td>
<td><c:out value="${obj.ord}"/></td>
<td><c:out value="${obj.parent_cd}"/></td>
<td><c:out value="${obj.DEL_YN}"/></td>
<td><c:out value="${obj.USE_YN}"/></td>
</tr>
</c:forEach>
</table>
<c:set var = "userId" value = "myUserId"/>
or
<%
String userId = "myUserId";
%>
<sql:setDataSource var="db" driver="oracle.jdbc.driver.OracleDriver"
url="jdbc:oracle:thin:@localhost:1521/xe"
user="mydb"
password="1234" />
<sql:query dataSource="${db}" var="rs">
SELECT USER_ID, USER_NM, DEPT_CD FROM TBL_USER WHERE USER_ID = ? AND USER_NM = ?
<sql:param value = "${userId}" />
<sql:param value = "${userNm}" />
or
<sql:param value = "<%=userId %>" />
</sql:query>
<c:set var = "userId" value = "${rs.rows[0].user_id }"/>
<c:set var = "userNm" value = "${rs.rows[0].user_nm }"/>
<c:set var = "deptCd" value = "${rs.rows[0].dept_cd }"/>
<%
String userId = (String)pageContext.getAttribute("userId");
String userNm = (String)pageContext.getAttribute("userNm");
String deptCd = (String)pageContext.getAttribute("deptCd");
%>