개발 환경 구축
운영체제를 다루는 능력
운영체제는 크게 윈도우, 리눅스, 맥 계열, 모바일 계열(안드로이드, IOS)
운영체제 역할: 하드웨어와 응용쇼프트웨어의 중재자
예) 음악을 듣는다 -> 하드웨어: 스피커
소프트웨어:미디어 플레이어
>>운영체제는 하드웨어를 관리하고 미디어 플레이어가 실행되도록 한다.
윈도우 : GUI 기반 TUI 지원- 선점형
리눅스 : TUI 기반 GUI 지원- 2.4이하는 비선점형, 이후는 선택가능
*둘다 멀티태스킹(다중처리능력)을 지원한다.
멀티태스킹- 한개의 CPU로 두개 이상의 응용소프트웨어를 처리하는 것.
관련된 이론은 운영체제 교과에 cpu스케줄링
개발자와 관련된것은 Priority 스케줄링(우선순위로 처리)
선점형(대기중인 프로그램을 뺏는것)과 비선점형(기다리는 것)
GUI-사용자 편의성
TUI-개발자 입장에서의 인터페이스, 가볍고 안정적
TUI명령어
-디렉토리 이동: cd +디렉토리명(..은 상위폴더로 이동)
-디렉토리 내용보기: dir
-디렉토리 만들기: mkdir + 폴더명
-파일 만들기: copy con + 파일명
제어판
1.방화벽설정 - 보안
2.계정관리 - 사용자
3.네트워크 관리 - 인터넷 및 통신
4.하드웨어 관리 - 물리적인 장치
5.프로그램 관리 - 응용소프트웨어
JSP 게시판 만들기
1.1 인덱스 jsp
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
<h1>나의 홈페이지</h1>
<div>[home] <a href="BoardList">[게시판]</a></div>
</body>
</html>
1.2 게시판 리스트 jsp
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<link rel="stylesheet" type="text/css" href="./css/shopping.css">
</head>
<body>
<div id="wrap" align="center">
<h1>게시글 리스트</h1>
<table class="list" style="text-align: center;">
<tr>
<td colspan="5" style="border: white; text-align: right"><a
href="wrForm">게시글 등록</a></td>
</tr>
<tr>
<th>번호</th>
<th>제목</th>
<th>작성자</th>
<th>작성일</th>
<th>조회</th>
</tr>
<tr class="record">
<td>1</td>
<td><a href="#">즐거운 코딩</a></td>
<td>홍길동</td>
<td>2022.11.14</td>
<td>3</td>
</tr>
<tr class="record">
<td>2</td>
<td><a href="#">오늘 점심은 계란</a></td>
<td>조하영</td>
<td>2022.11.14</td>
<td>14</td>
</tr>
</table>
</div>
</body>
</html>
1.3 글쓰기 jsp
<%@ 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>Insert title here</title>
<link rel="stylesheet" type="text/css" href="./css/shopping.css">
</head>
<body>
<div id="wrap" align="">
<h1>게시글 등록</h1>
<form name="frm" method="post" action="wrAction">
<input type="hidden" name="command" value="board_write">
<table>
<tr>
<th>작성자</th>
<td><input type="text" name="name"> * 필수</td>
</tr>
<tr>
<th>비밀번호</th>
<td><input type="password" name="pass"> * 필수 (게시물 수정
삭제시 필요합니다.)</td>
</tr>
<tr>
<th>이메일</th>
<td><input type="text" name="email"></td>
</tr>
<tr>
<th>제목</th>
<td><input type="text" size="70" name="title"> * 필수</td>
</tr>
<tr>
<th>내용</th>
<td><textarea cols="70" rows="15" name="content"></textarea></td>
</tr>
</table>
<br>
<br> <input type="submit" value="등록"> <input type="reset"
value="다시 작성"> <input type="button" value="목록">
</form>
</div>
</body>
</html>
1.4 뷰 css파일
#wrap {
width: 971px; /* 1024*768로 해상도를 맞추어서 설계 */
/* 가운데 정렬을 위한 바깥쪽 여백 설정 */
margin: 0;
margin-left: auto;
margin-right: auto;
}
h1 {
color: green; /* 글 색상 */
}
table {
width : 100%;
border-collapse: collapse;
font-size: 12px; /* 글꼴 크기 */
line-height: 24px;
width: 100%; /* 줄 간격 */
}
table td, th {
border: #d3d3d3 solid 1px; /* 경계선 색상 스타일 굵기 */
padding: 5px; /* 안쪽 여백 */
}
th {
background: yellowgreen; /* 배경색 */
}
img {
width: 220px; /* 이미지 너비(가로) */
height: 300px; /* 이미지 높이(세로) */
}
a {
text-decoration: none; /* 링크 밑줄 없애기 */
color: black; /* 글 색상 */
}
a:HOVER {
text-decoration: underline; /* 밑줄 */
color: green; /* 글 색상 */
}
2.1 인덱스 컨트롤러
package com.human.controller;
import java.io.IOException;
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;
/**
* Servlet implementation class Controller
*/
@WebServlet("/Index")
public class Controller extends HttpServlet {
private static final long serialVersionUID = 1L;
/**
* @see HttpServlet#HttpServlet()
*/
public Controller() {
super();
// TODO Auto-generated constructor stub
}
/**
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
*/
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
String url = "index.jsp";
RequestDispatcher dispatcher = request.getRequestDispatcher(url);
dispatcher.forward(request, response);
}
/**
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
*/
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
doGet(request, response);
}
}
2.2 게시판 리스트 컨트롤러
package com.human.controller;
import java.io.IOException;
import java.util.ArrayList;
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;
/**
* Servlet implementation class BoardList
*/
@WebServlet("/BoardList")
public class BoardList extends HttpServlet {
private static final long serialVersionUID = 1L;
/**
* @see HttpServlet#HttpServlet()
*/
public BoardList() {
super();
// TODO Auto-generated constructor stub
}
/**
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
*/
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
//데이터베이스 접근
ArrayList<String> bList = new ArrayList<>();
//포워딩
String url = "/bbs/list.jsp";
RequestDispatcher dispatcher = request.getRequestDispatcher(url);
request.setAttribute("bList", bList);
dispatcher.forward(request, response);
}
/**
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
*/
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
doGet(request, response);
}
}
2.3 글쓰기 폼 컨트롤러
package com.human.controller;
import java.io.IOException;
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;
/**
* Servlet implementation class wrForm
*/
@WebServlet("/wrForm")
public class wrForm extends HttpServlet {
private static final long serialVersionUID = 1L;
/**
* @see HttpServlet#HttpServlet()
*/
public wrForm() {
super();
// TODO Auto-generated constructor stub
}
/**
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response)
*/
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
String url = "bbs/wrForm.jsp";
RequestDispatcher dispatcher = request.getRequestDispatcher(url);
dispatcher.forward(request, response);
}
/**
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
*/
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
// TODO Auto-generated method stub
doGet(request, response);
}
}
2.4 글등록 컨트롤러
package com.human.controller;
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;
import com.human.dao.BoardDAO;
import com.human.vo.BoardVO;
/**
* Servlet implementation class wrAction
*/
@WebServlet("/wrAction")
public class wrAction extends HttpServlet {
private static final long serialVersionUID = 1L;
/**
* @see HttpServlet#HttpServlet()
*/
public wrAction() {
super();
// TODO Auto-generated constructor stub
}
/**
* @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse
* response)
*/
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
// TODO Auto-generated method stub
BoardDAO boardDao = new BoardDAO();
request.setCharacterEncoding("UTF-8");//받은 파라미터 인코딩
response.setContentType("text/html; charset=UTF-8");
String name = request.getParameter("name");
String pass = request.getParameter("pass");
String email = request.getParameter("email");
String title = request.getParameter("title");
String content = request.getParameter("content");
BoardVO boardVo = new BoardVO();
boardVo.setName(name);
boardVo.setPass(pass);
boardVo.setEmail(email);
boardVo.setTitle(title);
boardVo.setContent(content);
boardDao.insert(boardVo);
// DB insert작업
System.out.println(name + "/" + pass + "/" + email + "/" + title + "/" + content);
response.sendRedirect("BoardList");
}
/**
* @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse
* response)
*/
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
// TODO Auto-generated method stub
doGet(request, response);
}
}
3.1 DAO
package com.human.dao;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.SQLException;
import com.human.vo.BoardVO;
public class BoardDAO {
private Connection conn = null;
public BoardDAO(){
try {
Class.forName("oracle.jdbc.driver.OracleDriver");
System.out.println("로드성공");
} catch (ClassNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
System.out.println("로드실패");
}
}
public boolean connect() {
try {
conn = DriverManager.getConnection("jdbc:oracle:thin:@humanDB_high?TNS_ADMIN = C:/Users/human/Desktop/Wallet_humanDB", "admin",
"Jb21499549954.");
System.out.println("연결성공");
return true;
} catch (SQLException e) {
// TODO Auto-generated catch block
System.out.println("연결실패");
e.printStackTrace();
return false;
}
}
public void insert(BoardVO boardVo) {
if(connect()) {
String sql="insert into board values (board_cnt.nextval,?,?,?,?,?,default,default)";
try {
PreparedStatement psmt = conn.prepareStatement(sql);
psmt.setString(1, boardVo.getName());
psmt.setString(2, boardVo.getEmail());
psmt.setString(3, boardVo.getTitle());
psmt.setString(4, boardVo.getContent());
psmt.setString(5, boardVo.getPass());
psmt.executeUpdate();
conn.close();
System.out.println("입력성공");
} catch (SQLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
System.out.println("입력실패");
}
}
}
}
3.2 VO
package com.human.vo;
public class BoardVO {
public int num;
public String name;
public String email;
public String title;
public String content;
public String pass;
public int cnt;
public String indate;
public int getNum() {
return num;
}
public void setNum(int num) {
this.num = num;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getContent() {
return content;
}
public void setContent(String content) {
this.content = content;
}
public String getPass() {
return pass;
}
public void setPass(String pass) {
this.pass = pass;
}
public int getCnt() {
return cnt;
}
public void setCnt(int cnt) {
this.cnt = cnt;
}
public String getIndate() {
return indate;
}
public void setIndate(String indate) {
this.indate = indate;
}
}