์ƒˆ์†Œ์‹

์ธ๊ธฐ ๊ฒ€์ƒ‰์–ด

๐ŸŒ WEB/๐Ÿ“ฐ HTML

HTML ๊ธฐ์ดˆ - ์‹ค์Šต ( ๊ฒŒ์‹œํŒ ๋งŒ๋“ค๊ธฐ )

  • -
๋ฐ˜์‘ํ˜•

๋กœ๊ทธ์ธ ํŽ˜์ด์ง€ , ๊ฒŒ์‹œํŒ ๋งŒ๋“ค๊ธฐ , ๊ฒŒ์‹œ๊ธ€ ์—…๋กœ๋“œ ๋ฐ ํ™•์ธ

<!-- login.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>
	<form action="login-ok.jsp" method="post">
		ID : <input type="text" name="id"><br>
		PW : <input type="password" name="pw"><br>
		<input type="submit" value="๋กœ๊ทธ์ธ">
	</form>
</body>
</html>

<!-- board.jsp
๋ฉ”์ธ ๊ฒŒ์‹œํŒ ๊ตฌ์กฐ -->

<%@page import="board.BoardVO"%>
<%@page import="java.util.ArrayList"%>
<%@ 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>
	<table border="1">
		<tr>
			<td>No</td>	<td>๊ธ€์ œ๋ชฉ</td>	<td>์ž‘์„ฑ์ž</td>	<td>์ž‘์„ฑ์ผ</td>
		</tr>
		<%
			ArrayList<BoardVO> list =(ArrayList<BoardVO>)session.getAttribute("list");
			if(list !=null){

			for(BoardVO vo : list ){
		%>
		<tr>
			<td><%=vo.getNo() %></td>	<td><a href="board-detail.jsp?no=<%=vo.getNo() %>"><%=vo.getTitle() %></a></td>	<td><%=vo.getAuthor() %></td>	<td><%=vo.getNowDate() %></td>
		</tr>
		<%
			}
			}
		%>
		
	</table>
	<button onclick="javascript:location.href='board-regist.jsp'">์ƒˆ ๊ธ€ ๋“ฑ๋ก</button>
</body>
</html>

<!-- board-detail.jsp
๊ฒŒ์‹œํŒ ๊ฒŒ์‹œ๊ธ€ ํ™•์ธ -->


<%@page import="board.BoardVO"%>
<%@page import="java.util.ArrayList"%>
<%@ 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>
	<%
		ArrayList<BoardVO> list = (ArrayList<BoardVO>)session.getAttribute("list");
		
		int no = Integer.parseInt(request.getParameter("no"));
		
		for (BoardVO vo : list){
			if(vo.getNo()==no){
	%>
	์ œ๋ชฉ : <%=vo.getTitle() %><br>
	์ž‘์„ฑ์ž :<%=vo.getAuthor() %> <br>
	์ž‘์„ฑ์ผ :<%=vo.getNowDate() %> <br>
	๋‚ด์šฉ : <%=vo.getContent() %><br>
	<%
			}
		}
	%>


</body>
</html>

<!--board-regist.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>
	<form action="board-regist-ok.jsp" method="post">
		no : <input type="text" name="no"><br>
		์ œ๋ชฉ : <input type="text" name="title"><br>
		๋‚ด์šฉ : <textarea name="content"></textarea><br>
		<input type="submit" value="๋“ฑ๋ก">
	</form>
	
</body>
</html>

<!-- login-ok.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>
	<%
		String id = request.getParameter("id");
		String pw = request.getParameter("pw");
		
		//DB์— id,pw๋ฅผ ๋„˜๊ฒจ์„œ ์‹ค์ œ ์กด์žฌํ•˜๋Š” ๊ณ„์ •์ธ์ง€ ํ™•์ธ
		
		if(id.equals("admin") && pw.equals("1234")){
			// ์„ฑ๊ณต
			session.setAttribute("session_id","id");
			response.sendRedirect("board.jsp");
		} else{
			// ์‹คํŒจ
			response.sendRedirect("login.jsp");
		}
		
	%>

</body>
</html>

 

<!-- board.regist-ok.jsp
๊ฒŒ์‹œํŒ ๋กœ์ง -->


<%@page import="board.BoardVO"%>
<%@page import="java.util.ArrayList"%>
<%@page import="java.text.SimpleDateFormat"%>
<%@page import="java.util.Date"%>
<%@ 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>
	<%
		request.setCharacterEncoding("utf-8");
		int no =Integer.parseInt(request.getParameter("no")); // NO
		String title = request.getParameter("title");	// ์ œ๋ชฉ
		String content = request.getParameter("content");	// ๋‚ด์šฉ
		String author = (String) session.getAttribute("session_id");	// ์ž‘์„ฑ์ž
		Date nowDate = new Date();	// ์ž‘์„ฑ์ผ
		
		SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		String date = sdf.format(nowDate);
		
		BoardVO vo = new BoardVO();
		vo.setNo(no);
		vo.setTitle(title);
		vo.setContent(content);
		vo.setAuthor(author);
		vo.setNowDate(date);
		
		ArrayList<BoardVO> list = (ArrayList<BoardVO>)session.getAttribute("list");
		if(list == null){
			list = new ArrayList<BoardVO>();
		}else{
			list.add(vo);
			session.setAttribute("list", list);
			
			
		}
		
		response.sendRedirect("board.jsp");
	
	%>

</body>
</html>

 

๋ฐ˜์‘ํ˜•

'๐ŸŒ WEB > ๐Ÿ“ฐ HTML' ์นดํ…Œ๊ณ ๋ฆฌ์˜ ๋‹ค๋ฅธ ๊ธ€

HTML ๊ธฐ์ดˆ - ์„ธ์…˜  (0) 2022.06.15
HTML ๊ธฐ์ดˆ - ์ฟ ํ‚ค  (0) 2022.06.15
HTML ๊ธฐ์ดˆ - JSP  (0) 2022.06.15
HTML ๊ธฐ์ดˆ - CSS  (0) 2022.06.15
HTML ๊ธฐ์ดˆ - ๋กœ๊ทธ์ธ ์ฐฝ  (0) 2022.06.15
Contents

ํฌ์ŠคํŒ… ์ฃผ์†Œ๋ฅผ ๋ณต์‚ฌํ–ˆ์Šต๋‹ˆ๋‹ค

์ด ๊ธ€์ด ๋„์›€์ด ๋˜์—ˆ๋‹ค๋ฉด ๊ณต๊ฐ ๋ถ€ํƒ๋“œ๋ฆฝ๋‹ˆ๋‹ค.