과정평가_정산기_기록/수강신청 도우미 사이트

(교과목 추가)과정평가형 정보처리산업기사 수강신청 도우미 사이트

값을변경 2022. 2. 13. 16:36

index.jsp 작성 버튼 누르면 들어오는 화면

 

<select name="lecturer">
	<option selected="selected">담당강사선택</option>
	<option value="1">김교수</option>
    ...
<input type="radio" name="week" value="1">월

 

HTML 전체

더보기
<%@ 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>

<jsp:include page="header.jsp"></jsp:include>

<section>
	<h3 class="H3_addpage">교과목 추가</h3>
	<form name="majorAddForm" action="majorAddAction.jsp">
	<table>
		<tr>
			<td>교과목 코드</td>
			<td><input name="id"></td>
		</tr>
		<tr>
			<td>과목명</td>
			<td><input name="name"></td>
		</tr>
		<tr>
			<td>담당강사</td>
			<td>
				<select name="lecturer">
					<option selected="selected">담당강사선택</option>
					<option value="1">김교수</option>
					<option value="2">이교수</option>
					<option value="3">박교수</option>
					<option value="4">우교수</option>
					<option value="5">최교수</option>
					<option value="6">강교수</option>
					<option value="7">황교수</option>
				</select>		
			</td>
		</tr>
		<tr>
			<td>학점</td>
			<td><input name="credit"></td>
		</tr>
		<tr>
			<td>요일</td>
			<td>
				<input type="radio" name="week" value="1">월
				<input type="radio" name="week" value="2">화
				<input type="radio" name="week" value="3">수
				<input type="radio" name="week" value="4">목
				<input type="radio" name="week" value="5">금
			</td>
		</tr>
		<tr>
			<td>시작</td>
			<td><input name="start_hour"></td>
		</tr>
		<tr>
			<td>종료</td>
			<td><input name="end_hour"></td>
		</tr>
	</table>
		<div class="majorAddBtn">
			<input type="button" value="목록" onclick="location.href='index.jsp'">
			<input type="submit" value="완료">
		</div>
	</form>
</section>

<jsp:include page="footer.jsp"></jsp:include>

</body>
</html>

 

 

form -> addAction.jsp

더보기
	String id = request.getParameter("id");
	String name = request.getParameter("name");
	String credit = request.getParameter("credit");
	String lecturer = request.getParameter("lecturer");
	String week = request.getParameter("week");
	String start_hour = request.getParameter("start_hour");
	String end_hour = request.getParameter("end_hour");
	
	Connection con = null;
	PreparedStatement pstmt = null;
	
	try{
		con = dbcon.getConnection();
		String sql = "insert into course03 values (?,?,?,?,?,?,?)";
		pstmt = con.prepareStatement(sql);
		pstmt.setString(1, id);
		pstmt.setString(2, name);
		pstmt.setString(3, credit);
		pstmt.setString(4, lecturer);
		pstmt.setString(5, week);
		pstmt.setString(6, start_hour);
		pstmt.setString(7, end_hour);
		pstmt.executeUpdate();
		
		response.sendRedirect("index.jsp");
		
		if(pstmt!=null) pstmt.close();
		if(con!=null) con.close();
	}catch(Exception e){
		e.printStackTrace();
	}