<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ include file="top.jsp" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<section>
<h3>사원정보</h3>
<form action="sawoninput.do">
<table border="1" align="center">
<tr>
<th>아이디</th>
<td><input type="text" name="id"></td>
</tr>
<tr>
<th>이름</th>
<td><input type="text" name="name"></td>
</tr>
<tr>
<th>주민번호</th>
<td><input type="text" name="jumin"></td>
</tr>
<tr>
<th>부서명</th>
<td>
<select name="busea">
<option value="인사부">인사부
<option value="자재부">자재부
<option value="총무부">총무부
</select>
</td>
</tr>
<tr>
<th>직위</th>
<td>
<select name="grade">
<option value="이사">이사
<option value="부장">부장
<option value="과장">과장
<option value="대리">대리
<option value="사원">사원
</select>
</td>
</tr>
<tr>
<th>가족수</th>
<td>
<select name="fsu">
<option value="1">1
<option value="2">2
<option value="3">3
<option value="4">4이상
</select>
</td>
</tr>
<tr>
<td colspan="2" align="center">
<input type="submit" value="전송">
<input type="reset" value="리셋">
</td>
</tr>
</table>
</form>
</section>
<jsp:include page="footer.jsp"></jsp:include>
</html>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>
<%@ include file="top.jsp" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<section>
<table border="1" align="center" width="800px">
<tr>
<th>아이디</th><th>이름</th><th>부서명</th><th>나이</th>
<th>성별</th><th>본봉</th><th>가족수당</th><th>총급여</th>
</tr>
<c:forEach items="${lista}" var="dto">
<tr>
<td>${dto.id}</td><td>${dto.name}</td><td>${dto.busea}</td>
<td>${dto.age}</td><td>${dto.sb}</td>
<td>
<fmt:formatNumber value="${dto.bonbong}" pattern="#,##0"/>
</td>
<td>
<fmt:formatNumber value="${dto.familysudang}" pattern="#,##0"/>
</td>
<td>
<fmt:formatNumber value="${dto.pay}" pattern="#,##0"/>
</td>
</tr>
</c:forEach>
</table>
</section>
<jsp:include page="footer.jsp"/>
</html>
package com.ezen;
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;
@WebServlet("*.do")
public class FrontController extends HttpServlet {
private static final long serialVersionUID = 1L;
public FrontController() {
super();
}
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
String uri = request.getRequestURI();
String path = request.getContextPath();
String fname = uri.substring(path.length());
service service = null;
String vpage = null;
if(fname.equals("/input.do")) {
//Input 이라는 클래스로 service 객체를 만든 이유
service = new Input();
service.aaa(request, response);
vpage="reset.jsp";
}
else if(fname.equals("/out.do")) {
service = new Output();
service.aaa(request, response);
vpage="out.jsp";
}
else if(fname.equals("/modify.do")) {
service = new modify();
service.aaa(request, response);
vpage="index.jsp";
}
else if(fname.equals("/delete.do")) {
service=new Delete();
service.aaa(request, response);
vpage="index.jsp";
}
else if(fname.equals("/search.do")) {
service=new Search();
service.aaa(request, response);
vpage="out2.jsp";
}
else if(fname.equals("/sawoninput.do")) {
service=new Sawoninput();
service.aaa(request, response);
vpage="index.jsp";
}
else if(fname.equals("/sawonout.do")) {
service=new Sawonout();
service.aaa(request, response);
vpage="out3.jsp";
}
else if(fname.equals("/officeinput.do")) {
service=new Officeinput();
service.aaa(request, response);
vpage="index.jsp";
}
else if(fname.equals("/officeout.do")) {
service = new OfficeOut();
service.aaa(request, response);
vpage="out4.jsp";
}
else if(fname.equals("/officemodify.do")) {
service = new OfficeModify();
service.aaa(request, response);
vpage="index.jsp";
}
RequestDispatcher rd = request.getRequestDispatcher(vpage);
rd.forward(request, response);
}
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
doGet(request, response);
}
}
package com.ezen;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class Sawoninput implements service{
@Override
public void aaa(HttpServletRequest request, HttpServletResponse response) {
SawonDAO sdao;
try {
sdao = new SawonDAO();
sdao.insert(request);
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
}
}
package com.ezen;
import java.util.ArrayList;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class Sawonout implements service{
@Override
public void aaa(HttpServletRequest request, HttpServletResponse response) {
try {
SawonDAO sdao = new SawonDAO();
ArrayList<SawonDTO> list = sdao.out();
request.setAttribute("lista", list);
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
}
}
package com.ezen;
import java.io.UnsupportedEncodingException;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.GregorianCalendar;
import javax.servlet.http.HttpServletRequest;
public class SawonDAO {
Connection con;
PreparedStatement psmt;
ResultSet rs,rs1,rs2;
String driver="oracle.jdbc.driver.OracleDriver";
String url = "jdbc:oracle:thin:@localhost:1521:xe";
ArrayList<SawonDTO> list = new ArrayList<SawonDTO>();
public SawonDAO() throws ClassNotFoundException {
Class.forName(driver);
try {
con=DriverManager.getConnection(url, "ezen", "12345");
} catch (SQLException e) {
e.printStackTrace();
}
}
public void insert(HttpServletRequest request) {
try {
request.setCharacterEncoding("utf-8");
int id = Integer.parseInt(request.getParameter("id"));
String name = request.getParameter("name");
String jumin = request.getParameter("jumin");
String busea = request.getParameter("busea");
String grade = request.getParameter("grade");
int fsu = Integer.parseInt(request.getParameter("fsu"));
String sql = "insert into db02141 values (?,?,?,?,?,?)";
try {
psmt = con.prepareStatement(sql);
psmt.setInt(1, id);
psmt.setString(2, name);
psmt.setString(3, jumin);
psmt.setString(4, busea);
psmt.setString(5, grade);
psmt.setInt(6, fsu);
psmt.executeUpdate();
} catch (SQLException e) {
e.printStackTrace();
}
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
}
public ArrayList<SawonDTO> out() {
String sql = "select * from db02141";
try {
psmt = con.prepareStatement(sql);
rs = psmt.executeQuery();
while(rs.next()) {
int id = rs.getInt(1);
String name = rs.getString(2);
String jumin = rs.getString(3); // 나이..성별
String busea = rs.getString(4);
String grade = rs.getString(5); // 직위..분봉금액
int fsu = rs.getInt(6); // 가족수 -> 가족수당
//
GregorianCalendar gc = new GregorianCalendar();
char bi = jumin.charAt(7); //801230-1234567
int nowYear = gc.get(Calendar.YEAR);
int birthYear = 0;
if(bi=='1' || bi=='2') {
birthYear = Integer.parseInt(jumin.substring(0, 2))+1900;
}
else {
birthYear = Integer.parseInt(jumin.substring(0, 2))+2000;
}
int age = nowYear - birthYear;
String sb = null;
if (bi=='1'|| bi =='3')
sb = "남자";
else
sb= "여자";
int bonbong = 0;
String sql1 = "select * from bonbong where jikwe=?";
psmt = con.prepareStatement(sql1);
psmt.setString(1, grade);
rs1 = psmt.executeQuery();
if(rs1.next()) {
bonbong = rs1.getInt(2);
}
int fasudang = 0;
String sql2 = "select * from fasudang where count=?";
psmt = con.prepareStatement(sql2);
psmt.setInt(1, fsu);
rs2 = psmt.executeQuery();
if(rs2.next()) {
fasudang = rs2.getInt(2);
}
//
SawonDTO sdto = new SawonDTO();
sdto.setId(id);
sdto.setName(name);
sdto.setBusea(busea);
sdto.setAge(age);
sdto.setSb(sb);
sdto.setBonbong(bonbong);
sdto.setFamilysudang(fasudang);
sdto.setPay(bonbong+fasudang);
list.add(sdto);
}
} catch (SQLException e) {
e.printStackTrace();
}
return list;
}
}
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ include file="top.jsp" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<section>
<h3 align="center">근태관리입력</h3>
<form action="officeinput.do">
<table border="1" align="center">
<tr>
<th>이름</th>
<td><input type="text" name="name"></td>
</tr>
<tr>
<th>출근시간</th>
<td><input type="time" name="intime" value="09:00"></td>
</tr>
<tr>
<th>퇴근시간</th>
<td><input type="time" name="outtime" value="18:00"></td>
</tr>
<tr>
<td colspan="2" align="center">
<input type="submit" value="전송">
<input type="reset" value="리셋">
</td>
</tr>
</table>
</form>
</section>
<jsp:include page="footer.jsp"></jsp:include>
</html>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ include file="top.jsp" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<section>
<h3 align="center">근태관리출력</h3>
<table border="1" align="center" width="800px">
<tr>
<th>이름</th><th>출근시간</th><th>출근비고</th><th>퇴근시간</th>
<th>퇴근비고</th>
</tr>
<c:forEach items="${listb}" var="dto">
<tr>
<td>${dto.name}</td><td>${dto.intime}</td><td>${dto.inbigo}</td>
<td>${dto.outtime}</td><td>${dto.outbigo}</td>
</tr>
</c:forEach>
</table>
</section>
<jsp:include page="footer.jsp"/>
</html>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ include file="top.jsp" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<section>
<h3 align="center">근태관리수정</h3>
<form action="officemodify1.jsp">
<table border="1" align="center">
<tr>
<th>수정할 이름</th>
<td><input type="text" name="name"></td>
</tr>
<tr>
<td colspan="2" align="center">
<input type="submit" value="확인">
<input type="reset" value="리셋">
</td>
</tr>
</table>
</form>
</section>
<jsp:include page="footer.jsp"/>
</html>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ include file="top.jsp" %>
<%@ include file="dbcon.jsp" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<section>
<%!
String mname;
String name,intime,outtime;
%>
<%
request.setCharacterEncoding("utf-8");
mname=request.getParameter("name");
String sql = "select * from db02142 where name=?";
psmt = con.prepareStatement(sql);
psmt.setString(1, mname);
rs = psmt.executeQuery();
if(rs.next()) {
name = rs.getString(1);
intime = rs.getString(2);
outtime = rs.getString(3);
}
%>
<form action="officemodify.do">
<table border="1" align="center">
<tr>
<th>이름</th>
<td><input type="text" name="name" value="<%=name%>" readonly></td>
</tr>
<tr>
<th>출근시간</th>
<td><input type="time" name="intime" value="<%=intime%>"></td>
</tr>
<tr>
<th>퇴근시간</th>
<td><input type="time" name="outtime" value="<%=outtime%>"></td>
</tr>
<tr>
<td colspan="2" align="center">
<input type="submit" value="수정">
<input type="reset" value="리셋">
</td>
</tr>
</table>
</form>
</section>
<jsp:include page="footer.jsp"/>
</html>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ include file="top.jsp" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<section>
<h3 align="center">근태관리삭제</h3>
<form action="officedelete1.jsp">
<table border="1" align="center">
<tr>
<th>삭제할 이름</th>
<td><input type="text" name="name"></td>
</tr>
<tr>
<td colspan="2" align="center">
<input type="submit" value="삭제">
<input type="reset" value="리셋">
</td>
</tr>
</table>
</form>
</section>
<jsp:include page="footer.jsp"/>
</html>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ include file="top.jsp" %>
<%@ include file="dbcon.jsp" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<section>
<%!
String dname;
String name,intime,outtime;
%>
<%
request.setCharacterEncoding("utf-8");
dname = request.getParameter("name");
String sql = "select * from db02142 where name=?";
psmt = con.prepareStatement(sql);
psmt.setString(1, dname);
rs = psmt.executeQuery();
if(rs.next()) {
name = rs.getString(1);
intime = rs.getString(2);
outtime = rs.getString(3);
}
%>
<form action="officedelete.do">
<table border="1" align="center">
<tr>
<th>이름</th>
<td><input type="text" name="name" value="<%=name%>" readonly></td>
</tr>
<tr>
<th>출근시간</th>
<td><input type="time" name="intime" value="<%=intime%>"></td>
</tr>
<tr>
<th>퇴근시간</th>
<td><input type="time" name="outtime" value="<%=outtime%>"></td>
</tr>
<tr>
<td colspan="2" align="center">
<input type="submit" value="삭제">
<input type="reset" value="리셋">
</td>
</tr>
</table>
</form>
</section>
<jsp:include page="footer.jsp"/>
</html>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ include file="top.jsp" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<section>
<h3 align="center">근태관리검색</h3>
<form action="officesearch.do">
<table border="1" align="center">
<tr>
<th>검색할 자료</th>
<td>
<select name="item">
<option value="name">이름</option>
<option value="intime">출근시간</option>
<option value="outtime">출근시간</option>
</select>
</td>
</tr>
<tr>
<th>입력</th>
<td><input type="text" name="value"></td>
</tr>
<tr>
<td colspan="2" align="center">
<input type="submit" value="확인">
<input type="reset" value="리셋">
</td>
</tr>
</table>
</form>
</section>
<jsp:include page="footer.jsp"/>
</html>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ include file="top.jsp" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<section>
<table border="1" align="center" width="800px">
<caption><h4>근태 검색 결과</h4></caption>
<tr>
<th>이름</th><th>출근시간</th><th>출근비고</th><th>퇴근시간</th>
<th>퇴근비고</th>
</tr>
<c:forEach items="${listc}" var="dto">
<tr>
<td>${dto.name}</td><td>${dto.intime}</td><td>${dto.inbigo}</td>
<td>${dto.outtime}</td><td>${dto.outbigo}</td>
</tr>
</c:forEach>
</table>
</section>
<jsp:include page="footer.jsp"/>
</html>
package com.ezen;
public class OfficeDTO {
String name;
String intime,outtime;
String inbigo,outbigo;
public OfficeDTO() {
}
public OfficeDTO(String name, String intime, String outtime, String inbigo, String outbigo) {
super();
this.name = name;
this.intime = intime;
this.outtime = outtime;
this.inbigo = inbigo;
this.outbigo = outbigo;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getIntime() {
return intime;
}
public void setIntime(String intime) {
this.intime = intime;
}
public String getOuttime() {
return outtime;
}
public void setOuttime(String outtime) {
this.outtime = outtime;
}
public String getInbigo() {
return inbigo;
}
public void setInbigo(String inbigo) {
this.inbigo = inbigo;
}
public String getOutbigo() {
return outbigo;
}
public void setOutbigo(String outbigo) {
this.outbigo = outbigo;
}
}
package com.ezen;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class Officeinput implements service{
@Override
public void aaa(HttpServletRequest request, HttpServletResponse response) {
try {
OfficeDAO odao = new OfficeDAO();
odao.insert(request);
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
}
}
package com.ezen;
import java.util.ArrayList;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class OfficeOut implements service{
@Override
public void aaa(HttpServletRequest request, HttpServletResponse response) {
try {
OfficeDAO odao = new OfficeDAO();
ArrayList<OfficeDTO> list= odao.out();
request.setAttribute("listb", list);
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
}
}
package com.ezen;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class OfficeModify implements service{
@Override
public void aaa(HttpServletRequest request, HttpServletResponse response) {
try {
OfficeDAO odao = new OfficeDAO();
odao.modify(request);
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
}
}
package com.ezen;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class OfficeDelete implements service{
@Override
public void aaa(HttpServletRequest request, HttpServletResponse response) {
try {
OfficeDAO odao = new OfficeDAO();
String dname = request.getParameter("name");
odao.delete(dname);
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
}
}
package com.ezen;
import java.util.ArrayList;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
public class OfficeSearch implements service{
@Override
public void aaa(HttpServletRequest request, HttpServletResponse response) {
try {
OfficeDAO odao = new OfficeDAO();
ArrayList<OfficeDTO> list = odao.search(request);
request.setAttribute("listc", list);
} catch (ClassNotFoundException e) {
e.printStackTrace();
}
}
}
package com.ezen;
import java.io.UnsupportedEncodingException;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import javax.servlet.http.HttpServletRequest;
public class OfficeDAO {
Connection con;
PreparedStatement psmt;
ResultSet rs,rs1,rs2;
String driver="oracle.jdbc.driver.OracleDriver";
String url = "jdbc:oracle:thin:@localhost:1521:xe";
ArrayList<OfficeDTO> list = new ArrayList<OfficeDTO>();
public OfficeDAO() throws ClassNotFoundException {
Class.forName(driver);
try {
con=DriverManager.getConnection(url, "ezen", "12345");
} catch (SQLException e) {
e.printStackTrace();
}
}
public void insert(HttpServletRequest request) {
try {
request.setCharacterEncoding("utf-8");
String name = request.getParameter("name");
String intime = request.getParameter("intime");
String outtime = request.getParameter("outtime");
String sql = "insert into db02142 values (?,?,?)";
try {
psmt = con.prepareStatement(sql);
psmt.setString(1, name);
psmt.setString(2, intime);
psmt.setString(3, outtime);
psmt.executeUpdate();
} catch (SQLException e) {
e.printStackTrace();
}
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
}
public ArrayList<OfficeDTO> out() {
String sql = "select * from db02142";
try {
psmt = con.prepareStatement(sql);
rs = psmt.executeQuery();
while(rs.next()) {
String name = rs.getString(1);
String intime = rs.getString(2);
String outtime = rs.getString(3);
//
String inbigo = null;
if(Integer.parseInt(intime.substring(0, 2))>=9 &
Integer.parseInt(intime.substring(3, 5))>=1) {
inbigo = "지각";
}
else {
inbigo = "정상";
}
String outbigo = null;
if(Integer.parseInt(outtime.substring(0, 2))<=17 &
Integer.parseInt(outtime.substring(3, 5))<=59) {
outbigo = "조퇴";
}
else {
outbigo = "정상";
}
OfficeDTO odto = new OfficeDTO();
odto.setName(name);
odto.setIntime(intime);
odto.setOuttime(outtime);
odto.setInbigo(inbigo);
odto.setOutbigo(outbigo);
list.add(odto);
}
} catch (SQLException e) {
e.printStackTrace();
}
return list;
}
public void modify(HttpServletRequest request) {
try {
request.setCharacterEncoding("utf-8");
String name = request.getParameter("name");
String intime = request.getParameter("intime");
String outtime = request.getParameter("outtime");
String sql = "update db02142 set intime=?,outtime=? where name=?";
try {
psmt = con.prepareStatement(sql);
psmt.setString(1, intime);
psmt.setString(2, outtime);
psmt.setString(3, name);
psmt.executeUpdate();
} catch (SQLException e) {
e.printStackTrace();
}
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
}
public void delete(String dname) {
String sql = "delete from db02142 where name = ?";
try {
psmt = con.prepareStatement(sql);
psmt.setString(1, dname);
psmt.executeUpdate();
} catch (SQLException e) {
e.printStackTrace();
}
}
public ArrayList<OfficeDTO> search(HttpServletRequest request) {
String item = request.getParameter("item");
String value = request.getParameter("value");
String sql = "select * from db02142 where "+item+" like ?";
try {
psmt = con.prepareStatement(sql);
psmt.setString(1, '%'+value+'%');
rs = psmt.executeQuery();
while(rs.next()) {
String name = rs.getString(1);
String intime = rs.getString(2);
String outtime = rs.getString(3);
//
String inbigo = null;
if(Integer.parseInt(intime.substring(0, 2))>=9 &
Integer.parseInt(intime.substring(3, 5))>=1) {
inbigo = "지각";
}
else {
inbigo = "정상";
}
String outbigo = null;
if(Integer.parseInt(outtime.substring(0, 2))<=17 &
Integer.parseInt(outtime.substring(3, 5))<=59) {
outbigo = "조퇴";
}
else {
outbigo = "정상";
}
OfficeDTO odto = new OfficeDTO();
odto.setName(name);
odto.setIntime(intime);
odto.setOuttime(outtime);
odto.setInbigo(inbigo);
odto.setOutbigo(outbigo);
list.add(odto);
}
} catch (SQLException e) {
e.printStackTrace();
}
return list;
}
}
package com.ezen;
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;
@WebServlet("*.do")
public class FrontController extends HttpServlet {
private static final long serialVersionUID = 1L;
public FrontController() {
super();
}
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
String uri = request.getRequestURI();
String path = request.getContextPath();
String fname = uri.substring(path.length());
service service = null;
String vpage = null;
if(fname.equals("/input.do")) {
//Input 이라는 클래스로 service 객체를 만든 이유
service = new Input();
service.aaa(request, response);
vpage="reset.jsp";
}
else if(fname.equals("/out.do")) {
service = new Output();
service.aaa(request, response);
vpage="out.jsp";
}
else if(fname.equals("/modify.do")) {
service = new modify();
service.aaa(request, response);
vpage="index.jsp";
}
else if(fname.equals("/delete.do")) {
service=new Delete();
service.aaa(request, response);
vpage="index.jsp";
}
else if(fname.equals("/search.do")) {
service=new Search();
service.aaa(request, response);
vpage="out2.jsp";
}
else if(fname.equals("/sawoninput.do")) {
service=new Sawoninput();
service.aaa(request, response);
vpage="index.jsp";
}
else if(fname.equals("/sawonout.do")) {
service=new Sawonout();
service.aaa(request, response);
vpage="out3.jsp";
}
else if(fname.equals("/officeinput.do")) {
service=new Officeinput();
service.aaa(request, response);
vpage="index.jsp";
}
else if(fname.equals("/officeout.do")) {
service = new OfficeOut();
service.aaa(request, response);
vpage="out4.jsp";
}
else if(fname.equals("/officemodify.do")) {
service = new OfficeModify();
service.aaa(request, response);
vpage="index.jsp";
}
else if(fname.equals("/officedelete.do")) {
service = new OfficeDelete();
service.aaa(request, response);
vpage="index.jsp";
}
else if(fname.equals("/officesearch.do")) {
service = new OfficeSearch();
service.aaa(request, response);
vpage="officeout2.jsp";
}
RequestDispatcher rd = request.getRequestDispatcher(vpage);
rd.forward(request, response);
}
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
doGet(request, response);
}
}
'JSP' 카테고리의 다른 글
230216_서블릿 (0) | 2023.02.16 |
---|---|
230215_서블릿 (0) | 2023.02.15 |
230213_서블릿 (0) | 2023.02.13 |
230210_서블릿 (0) | 2023.02.10 |
230209_서블릿 (0) | 2023.02.09 |
댓글