주기함수(Life Cycle)
init() : 맨 처음에 1번만 호출
↓
service() - doGet() : 클라이언트가 요청시마다 호출
- doPost()
↓
destroy()
서비스
1. get방식
: default
: 주소표시줄(Query String)를 통해서 이동
: 이동되는 데이터가 보인다
: 이동되는 데이터가 문자열만(String) 처리
2. post방식
: 클라이언트가 post로 요청 시에만 적용
: 내부적으로(페이지 단위) 이동
: 이동되는 데이터가 안 보인다.
: 대량 데이터
이걸 add 해주면 자동으로 어노테이션을 생성해준다 !!
create table guestbook(
seq number primary key, -- 시퀀스 객체로부터 값을 얻어온다
name varchar2(30),
email varchar2(30),
homepage varchar2(35),
subject varchar2(500) not null, -- 재목
content varchar2(4000) not null, -- 내용
logtime date);
create sequence seq_guestbook nocycle nocache;
Dynamiv Web Project : guestbookServlet
guestbook.service
GuestbookWriteServlet.java
guestbook.bean
GuestbookDTO.java
guestbook.dao
GuestbookDAO.java
sql
guestbook.sql
guestbook
guestbookWrite.html
guestbookWrite.html
제목, 내용은 유효성 검사
GuestbookWriteServlet.java
1. 데이터
2. DB name, email, homepage, subject, content (데이터 5개 보내야한다.) -- GuestbookDTO에 담아준다. -- DAO로 보냄
3. 응답
GuestbookDAO.java
1. diver loading
2. Connection
3. PreparedStatement
guestbookWrite
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<style type="text/css">
table {
border-collapse: collapse;
}
th, td {
padding: 5px;
}
#subjectDiv, #contentDiv {
color: red;
font-size: 8px;
font-weight: bold;
}
</style>
</head>
<body>
<form id="guestbookWriteForm" method="post" action="/guestbookServlet/write">
<table border="1" >
<tr>
<th width="125">작성자</th>
<td><input type="text" name="name" size="25" placeholder="작성자 입력"/></td>
</tr>
<tr>
<th>이메일</th>
<td><input type="email" name="email" size="40" placeholder="이메일 입력"/></td>
</tr>
<tr>
<th>홈페이지</th>
<td><input type="text" name="homepage" size="50" placeholder="http://"/></td>
</tr>
<tr>
<th>제목</th>
<td>
<input type="text" name="subject" id="subject" size="65" placeholder="제목 입력"/>
<div id="subjectDiv"></div>
</td>
</tr>
<tr>
<th>내용</th>
<td>
<textarea name="content" id="content" cols="65" rows="20"></textarea>
<div id="contentDiv"></div>
</td>
</tr>
<tr>
<td colspan="2" align="center">
<input type="submit" id="writeBtn" value="글작성" />
<input type="reset" value="다시작성" />
<input type="button" value="글목록" />
</td>
</tr>
</table>
</form>
<script type="text/javascript" src="http://code.jquery.com/jquery-3.7.1.min.js"></script>
<script type="text/javascript">
$(function () {
$('#writeBtn').click(function(){
$('#subjectDiv').empty();
$('#contentDiv').empty();
if($('#subject').val() == ''){
$('#subjectDiv').html('제목을 입력해주세요.');
$('#subject').focus();
}else if($('#content').val() == ''){
$('#contentDiv').html('내용을 입력해주세요.');
$('#content').focus();
}else
$('#guestbookWriteForm').submit();
});
});
</script>
</body>
</html>
guestbookWrite
GuestbookWriteServlet.java
package guestbook.service;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
@WebServlet("/write")
public class GuestbookWriteServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
//데이터
//한글처리 - post 방식
String name = request.getParameter("name");
String email = request.getParameter("email");
String homepage = request.getParameter("homepage");
String subject = request.getParameter("subject");
String content = request.getParameter("content");
System.out.println(name);
//DB
//응답
}
}
post 방식은 따로 한글처리를 해줘야한다. 아니면 이렇게 한글이 깨진다.
request.setCharacterEncoding("UTF-8");
이제 깨지지 않는거 확인할 수 있다.
GuestbookDTO.java
package guestbook.bean;
import java.util.Date;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
public class GuestbookDTO {
private int seq;
private String name;
private String email;
private String homepage;
private String subject;
private String content;
private Date logtime;
}
GuestbookDAO.java
오라클 DB와 연결작업
package guestbook.dao;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import guestbook.bean.GuestbookDTO;
public class GuestbookDAO {
private String driver = "oracle.jdbc.driver.OracleDriver";
private String url = "jdbc:oracle:thin:@localhost:1521:xe";
private String username = "C##JAVA";
private String password = "1234";
private Connection con;
private PreparedStatement pstmt;
private ResultSet rs;
private static GuestbookDAO guestbookDAO = new GuestbookDAO();
public static GuestbookDAO getInstance() {
return guestbookDAO;
}
public GuestbookDAO() {
try {
Class.forName(driver);
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
}
public void getConnection() {
try {
con = DriverManager.getConnection(url, username, password);
} catch (SQLException e) {
e.printStackTrace();
}
}
글작성한 내용을 DB에 넣기위한 guestbookWrite 함수
public void guestbookWrite(GuestbookDTO guestbookDTO) {
getConnection();
String sql = "insert into guestbook values(seq_guestbook.nextval,?,?,?,?,?,sysdate)";
try {
pstmt = con.prepareStatement(sql); //생성
// ? 데이터 매핑
pstmt.setString(1, guestbookDTO.getName());
pstmt.setString(2, guestbookDTO.getEmail());
pstmt.setString(3, guestbookDTO.getHomepage());
pstmt.setString(4, guestbookDTO.getSubject());
pstmt.setString(5, guestbookDTO.getContent());
pstmt.executeUpdate(); //실행 - 개수 리턴
} catch (SQLException e) {
e.printStackTrace();
}finally {
try {
if(pstmt != null)
pstmt.close();
if(con != null)
con.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
}
}
예전에는 실행한 개수를 리턴해서 실행이 잘 됐는지 확인했다면 이제는 그냥 실행만 시켜주고 끝
select * from guestbook;
버튼 추가
package guestbook.service;
import java.io.IOException;
import java.io.PrintWriter;
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 guestbook.bean.GuestbookDTO;
import guestbook.dao.GuestbookDAO;
@WebServlet("/write")
public class GuestbookWriteServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
//데이터
request.setCharacterEncoding("UTF-8");
//한글처리 - post 방식
String name = request.getParameter("name");
String email = request.getParameter("email");
String homepage = request.getParameter("homepage");
String subject = request.getParameter("subject");
String content = request.getParameter("content");
String logtime = request.getParameter("logtime");
GuestbookDTO guestbookDTO = new GuestbookDTO();
guestbookDTO.setName(name);
guestbookDTO.setEmail(email);
guestbookDTO.setHomepage(homepage);
guestbookDTO.setSubject(subject);
guestbookDTO.setContent(content);
guestbookDTO.setLogtime(logtime);
//DB
GuestbookDAO guestbookDAO = GuestbookDAO.getInstance(); //싱글톤
guestbookDAO.guestbookWrite(guestbookDTO);
//응답
response.setContentType("text/html; charset=UTF-8");;
PrintWriter out = response.getWriter();
out.println("<html>");
out.println("<body>");
out.println("<h3>작성하신 글을 저장하였습니다.</h3>");
out.println("<br><br>");
out.println("<input type='button' value='뒤로' style='color: red' onclick='history.go(-1)'/>");
out.println("<input type='button' value='글목록' style='color: red' onclick=\"location.href='guestbook/guestbookList.html'\"/>");
out.println("</body>");
out.println("</html>");
}
}
guestbookList.html
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Guestbook List</title>
<style type="text/css">
table {
border-collapse: collapse;
}
th, td {
padding: 5px;
}
td {
width: 100px;
}
</style>
</head>
<body>
<table border="1">
</table>
<hr/>
<script type="text/javascript" src="http://code.jquery.com/jquery-3.7.1.min.js"></script>
<script type="text/javascript">
$(function () {
$.ajax({
type: 'post',
url: '/guestbookServlet/list',
dataType: 'json',
success: function(data){
$.each(data, function(index, item){
let row = `
<tr>
<th>작성자</th>
<td>${item.name}</td>
<th>작성일</th>
<td>${item.logtime}</td>
</tr>
<tr>
<th>이메일</th>
<td colspan="3">${item.email}</td>
</tr>
<tr>
<th>홈페이지</th>
<td colspan="3">${item.homepage}</td>
</tr>
<tr>
<th>제목</th>
<td colspan="3">${item.subject}</td>
</tr>
<tr>
<td colspan="4" height="100">${item.content}</td>
</tr>
`;
$('table').append(row);
});
},
error: function(e){
console.log(e);
}
});
});
</script>
</body>
</html>
GuestbookDAO.java
public ArrayList<GuestbookDTO> guestbookList(){
ArrayList<GuestbookDTO> guestbookDTO = new ArrayList<GuestbookDTO>();
getConnection();
String sql = "select * from guestbook";
try {
pstmt = con.prepareStatement(sql);
rs = pstmt.executeQuery();
SimpleDateFormat sdf = new SimpleDateFormat("yyyy.MM.dd");
while(rs.next()) {
GuestbookDTO dto = new GuestbookDTO();
dto.setName(rs.getString("name"));
dto.setEmail(rs.getString("email"));
dto.setHomepage(rs.getString("homepage"));
dto.setSubject(rs.getString("subject"));
dto.setContent(rs.getString("content"));
dto.setLogtime(rs.getString("logtime"));
guestbookDTO.add(dto);
}
} catch (SQLException e) {
e.printStackTrace();
}finally {
try {
if(rs != null)
rs.close();
if(pstmt != null)
pstmt.close();
if(con != null)
con.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
return guestbookDTO;
}
GuestbookListServlet.java
package guestbook.service;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
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 org.json.JSONArray;
import org.json.JSONObject;
import guestbook.bean.GuestbookDTO;
import guestbook.dao.GuestbookDAO;
@WebServlet("/list")
public class GuestbookListServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
//1. 데이터 x
// DB에서 데이터 가져오기
GuestbookDAO guestbookDAO = GuestbookDAO.getInstance(); // 싱글톤
ArrayList<GuestbookDTO> guestbookList = guestbookDAO.guestbookList();
// JSON 배열 생성
JSONArray jsonArray = new JSONArray();
for (GuestbookDTO guestbook : guestbookList) {
JSONObject jsonObject = new JSONObject();
jsonObject.put("name", guestbook.getName());
jsonObject.put("email", guestbook.getEmail());
jsonObject.put("homepage", guestbook.getHomepage());
jsonObject.put("subject", guestbook.getSubject());
jsonObject.put("content", guestbook.getContent());
jsonObject.put("logtime", guestbook.getLogtime());
jsonArray.put(jsonObject);
}
// 응답
response.setContentType("application/json; charset=UTF-8");
PrintWriter out = response.getWriter();
String json = jsonArray.toString();
out.print(json);
}
}
GuestbookWriteServlet.java
1. 뒤로, 글목록 버튼 만들기
onclick='history.go(-1)'
onclick=\"location.href='/guestbookServlet/list?pg=1'\"
- 이렇게 따옴표가 헷갈릴 때는 다른 데에서 쓰고 복붙하면 알아서 해결해준다 !
package guestbook.service;
import java.io.IOException;
import java.io.PrintWriter;
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 guestbook.bean.GuestbookDTO;
import guestbook.dao.GuestbookDAO;
@WebServlet("/write")
public class GuestbookWriteServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
//데이터
request.setCharacterEncoding("UTF-8");
//한글처리 - post 방식
String name = request.getParameter("name");
String email = request.getParameter("email");
String homepage = request.getParameter("homepage");
String subject = request.getParameter("subject");
String content = request.getParameter("content");
GuestbookDTO guestbookDTO = new GuestbookDTO();
guestbookDTO.setName(name);
guestbookDTO.setEmail(email);
guestbookDTO.setHomepage(homepage);
guestbookDTO.setSubject(subject);
guestbookDTO.setContent(content);
//DB
GuestbookDAO guestbookDAO = GuestbookDAO.getInstance(); //싱글톤
guestbookDAO.guestbookWrite(guestbookDTO);
//응답
response.setContentType("text/html; charset=UTF-8");;
PrintWriter out = response.getWriter();
out.println("<html>");
out.println("<body>");
out.println("<h3>작성하신 글을 저장하였습니다.</h3>");
out.println("<br><br>");
out.println("<input type='button' value='뒤로' style='color: red' onclick='history.go(-1)'/>");
out.println("<input type='button' value='글목록' style='color: red' onclick=\"location.href='/guestbookServlet/list?pg=1'\"/>");
out.println("</body>");
out.println("</html>");
}
}
GuestbookDAO.java
2. 글목록 담아올 guestbookList 함수 만들기
public List<GuestbookDTO> guestbookList(int startNum, int endNum){
List<GuestbookDTO> list = new ArrayList<GuestbookDTO>();
getConnection();
String sql = """
select * from
(select rownum rn, tt.*from
(select * from guestbook order by seq desc) tt
) where rn >=? and rn<=?
""";
try {
pstmt = con.prepareStatement(sql);
pstmt.setInt(1, startNum);
pstmt.setInt(2, endNum);
rs = pstmt.executeQuery();
while(rs.next()) {
GuestbookDTO guestbookDTO = new GuestbookDTO();
guestbookDTO.setSeq(rs.getInt("seq"));
guestbookDTO.setName(rs.getString("name"));
guestbookDTO.setEmail(rs.getString("email"));
guestbookDTO.setHomepage(rs.getString("homepage"));
guestbookDTO.setSubject(rs.getString("subject"));
guestbookDTO.setContent(rs.getString("content"));
guestbookDTO.setLogtime(rs.getDate("logtime"));
list.add(guestbookDTO);
}
} catch (SQLException e) {
e.printStackTrace();
list = null; // 리스트 초기화 시켜줘서 null 값으로 가게 만들어준다.
}finally {
try {
if(rs != null)
rs.close();
if(pstmt != null)
pstmt.close();
if(con != null)
con.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
return list;
}
GuestbookListServlet.java
3. DB에서 데이터 가져와서 응답해주기
package guestbook.service;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;
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 guestbook.bean.GuestbookDTO;
import guestbook.dao.GuestbookDAO;
@WebServlet("/list")
public class GuestbookListServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// DB에서 데이터 가져오기
GuestbookDAO guestbookDAO = GuestbookDAO.getInstance(); // 싱글톤
List<GuestbookDTO> list = guestbookDAO.guestbookList(startNum, endNum); //부모 = 자식
int totalA = guestbookDAO.getTotal(); //총글수
System.out.println(totalA);
//응답
response.setContentType("text/html; charset=UTF-8");;
PrintWriter out = response.getWriter();
out.println("<html>");
out.println("<body>");
if(list != null) {
for(GuestbookDTO guestbookDTO : list) {
out.println("<table border='1' style='border-collapse: collapse;'>");
out.println("<tr>");
out.println("<th width='100'>작성자</th>");
out.println("<td width='150' align='center'>" + guestbookDTO.getName() + "</td>");
out.println("<th width='100'>작성일</th>");
out.println("<td width='300' align='center'>" + guestbookDTO.getLogtime() + "</td>");
out.println("</tr>");
out.println("<tr>");
out.println("<th>이메일</th>");
out.println("<td colspan='3'>" + guestbookDTO.getEmail() + "</td>");
out.println("</tr>");
out.println("<tr>");
out.println("<th>홈페이지</th>");
out.println("<td colspan='3'>" + guestbookDTO.getHomepage() + "</td>");
out.println("</tr>");
out.println("<tr>");
out.println("<th>제목</th>");
out.println("<td colspan='3'>" + guestbookDTO.getSubject() + "</td>");
out.println("</tr>");
out.println("<tr>");
out.println("<td colspan='4' style='white-space: pre-wrap; word-wrap: break-word;'>" + guestbookDTO.getContent() + "</td>");
out.println("</tr>");
out.println("</table>");
out.println("<hr/>");
}
}
out.println("</body>");
out.println("</html>");
}
}
4. 1페이지당 3개씩 뿌려주기위한 작업하기
select * from
(select rownum rn, tt.*from
(select * from guestbook order by seq desc) tt
) where rn >=1 and rn<=3;
rownum을 이용해서 글을 3개만 반환하는 코드이다.
전체적으로 흐름을 한 번 봐보면
pg = 1 --- 1페이지일 때
select * from
(select rownum rn, tt.*from
(select * from guestbook order by seq desc) tt
) where rn >=1 and rn<=3;
pg = 2 --- 2페이지일 때
select * from
(select rownum rn, tt.*from
(select * from guestbook order by seq desc) tt
) where rn >=4 and rn<= 6;
즉 4를 startNum으로 설정할 수 있고 / 6을 endNum으로 설정할 수 있다.
startNum endNum
pg = 1 rn >=1 and rn<=3;
pg = 2 rn >=4 and rn<=6;
pg = 3 rn >=7 and rn<=9;
endNum부터 보면 pg가 1일 때 ----- 3 / pg가 2일 때 ----6 3의 배수로 움직이는 것을 볼 수 있다.
int endNum = pg * 3;
startNum은 endNum이 3일 때 --- 1 / endNum이 6일 때 --- 4 2만큼 작다는 것을 확인할 수 있다.
int startNum = endNum - 2;
GuestbookDAO
SQL 문 수정하기 !!
public List<GuestbookDTO> guestbookList(int startNum, int endNum){
List<GuestbookDTO> list = new ArrayList<GuestbookDTO>();
getConnection();
String sql = """
select * from
(select rownum rn, tt.*from
(select * from guestbook order by seq desc) tt
) where rn >=? and rn<=?
""";
try {
pstmt = con.prepareStatement(sql);
pstmt.setInt(1, startNum);
pstmt.setInt(2, endNum);
rs = pstmt.executeQuery();
while(rs.next()) {
GuestbookDTO guestbookDTO = new GuestbookDTO();
guestbookDTO.setSeq(rs.getInt("seq"));
guestbookDTO.setName(rs.getString("name"));
guestbookDTO.setEmail(rs.getString("email"));
guestbookDTO.setHomepage(rs.getString("homepage"));
guestbookDTO.setSubject(rs.getString("subject"));
guestbookDTO.setContent(rs.getString("content"));
guestbookDTO.setLogtime(rs.getDate("logtime"));
list.add(guestbookDTO);
}
} catch (SQLException e) {
e.printStackTrace();
list = null; // 리스트 초기화 시켜줘서 null 값으로 가게 만들어준다.
}finally {
try {
if(rs != null)
rs.close();
if(pstmt != null)
pstmt.close();
if(con != null)
con.close();
} catch (SQLException e) {
e.printStackTrace();
}
}
return list;
}
guestbookWrite.html에서 글목록으로
onclick="location.href= '/guestbookServlet/list?pg=1' " 이 코드 통해서 페이지수를 임의로 줌
( 원래는 받아오는 데이터가 없었지만 이로인해 받아오는 데이터가 생긴 것을 확인할 수 있다.)
package guestbook.service;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;
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 guestbook.bean.GuestbookDTO;
import guestbook.dao.GuestbookDAO;
@WebServlet("/list")
public class GuestbookListServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
//데이터
int pg =Integer.parseInt(request.getParameter("pg"));
//1페이지당 3개씩
int endNum = pg * 3;
int startNum = endNum - 2;
// DB에서 데이터 가져오기
GuestbookDAO guestbookDAO = GuestbookDAO.getInstance(); // 싱글톤
List<GuestbookDTO> list = guestbookDAO.guestbookList(startNum, endNum); //부모 = 자식
int totalA = guestbookDAO.getTotal(); //총글수
System.out.println(totalA);
//응답
response.setContentType("text/html; charset=UTF-8");;
PrintWriter out = response.getWriter();
out.println("<html>");
out.println("<body>");
if(list != null) {
for(GuestbookDTO guestbookDTO : list) {
out.println("<table border='1' style='border-collapse: collapse;'>");
out.println("<tr>");
out.println("<th width='100'>작성자</th>");
out.println("<td width='150' align='center'>" + guestbookDTO.getName() + "</td>");
out.println("<th width='100'>작성일</th>");
out.println("<td width='300' align='center'>" + guestbookDTO.getLogtime() + "</td>");
out.println("</tr>");
out.println("<tr>");
out.println("<th>이메일</th>");
out.println("<td colspan='3'>" + guestbookDTO.getEmail() + "</td>");
out.println("</tr>");
out.println("<tr>");
out.println("<th>홈페이지</th>");
out.println("<td colspan='3'>" + guestbookDTO.getHomepage() + "</td>");
out.println("</tr>");
out.println("<tr>");
out.println("<th>제목</th>");
out.println("<td colspan='3'>" + guestbookDTO.getSubject() + "</td>");
out.println("</tr>");
out.println("<tr>");
out.println("<td colspan='4' style='white-space: pre-wrap; word-wrap: break-word;'>" + guestbookDTO.getContent() + "</td>");
out.println("</tr>");
out.println("</table>");
out.println("<hr/>");
}
}
out.println("</body>");
out.println("</html>");
}
}
총 글의 개수를 반환하기
select count(*) from guestbook;
public int getTotal() {
int totalA = 0;
getConnection();
String sql = "select count(*) from guestbook";
try {
pstmt = con.prepareStatement(sql);
rs = pstmt.executeQuery();
while(rs.next()) {
totalA = rs.getInt(1);
}
} catch (SQLException e) {
e.printStackTrace();
}
return totalA;
}
rs.getInt(1) 사용
: rs.getInt("count(*)") 대신 rs.getInt(1)을 사용한다.
SQL에서 count(*)는 결과의 첫 번째(그리고 유일한) 컬럼이므로,
컬럼의 인덱스를 사용하여 값을 가져올 수 있다.
인덱스 1은 결과 집합의 첫 번째 컬럼을 의미한다.
'JSP & Servlet' 카테고리의 다른 글
DAY 46 JSP - Connection Pool / 로그인 / 쿠키(2024.09.05) (1) | 2024.09.06 |
---|---|
DAY 47 - 미니프로젝트(member) - 세션 / 회원정보 수정 / 글 작성 (2024.09.06) (2) | 2024.09.06 |
DAY 45 JSP - 주석 / 미니프로젝트(member) - 중복체크 ( 2024.09.04 ) (4) | 2024.09.04 |
DAY 45 Servlet - Guestbook2 ( 2024.09.04 ) (0) | 2024.09.04 |
DAY 43 - Servlet (2024.09.02) (0) | 2024.09.02 |