λ³Έλ¬Έ λ°”λ‘œκ°€κΈ°
JSP

[JSP] μ•‘μ…˜ νƒœκ·Έλ₯Ό ν™œμš©ν•œ ν…œν”Œλ¦Ώ νŽ˜μ΄μ§€ μž‘μ„±

by μ½”λ”©ν•˜λŠ” λΆ•μ–΄ 2021. 2. 10.
λ°˜μ‘ν˜•

β–Ά ν…œν”Œλ¦Ώ νŽ˜μ΄μ§€λ₯Ό μ‚¬μš©ν•˜λŠ” 이유

ν…œν”Œλ¦Ώ νŽ˜μ΄μ§€λŠ” λ ˆμ΄μ•„μ›ƒμ„ κ΅¬μ„±ν•˜κ³  각 μ˜μ—­μ˜ λ‚΄μš©μ€ λ‹€λ₯Έ νŽ˜μ΄μ§€μ—μ„œ κ°€μ Έμ˜€λ―€λ‘œ 전체 νŽ˜μ΄μ§€ ꡬ성 μˆ˜μ • μ‹œμ—λ„ 이 ν…œν”Œλ¦Ώ νŽ˜μ΄μ§€λ§Œ λ³€ν™˜μ‹œν‚€λ©΄ λ˜λ―€λ‘œ 맀우 νŽΈλ¦¬ν•˜λ‹€.

​

​

​

β–Ά ν…œν”Œλ¦Ώ νŽ˜μ΄μ§€μ˜ 섀계

ν…œν”Œλ¦Ώ νŽ˜μ΄μ§€μ˜ μ„€κ³„μ—μ„œ μ€‘μš”ν•œ 것은 λ ˆμ΄μ•„μ›ƒ ꡬ쑰λ₯Ό κ²°μ •ν•˜λŠ” 것이닀. ν…œν”Œλ¦Ώ νŽ˜μ΄μ§€ μžμ²΄κ°€ λ ˆμ΄μ•„μ›ƒ κ΅¬μ‘°λ‚˜ λ§ˆμ°¬κ°€μ§€μ΄κΈ° λ•Œλ¬Έμ΄λ‹€. ν…œν”Œλ¦Ώ νŽ˜μ΄μ§€ 섀계λ₯Ό μœ„ν•΄μ„œλŠ” μ‚¬μ΄νŠΈ ν™”λ©΄μ˜ 틀이 κ²°μ •λ˜μ–΄μ•Ό ν•œλ‹€.

​

​

​

β–Ά μ•‘μ…˜ νƒœκ·Έλ₯Ό μ΄μš©ν•œ ν…œν”Œλ¦Ώ νŽ˜μ΄μ§€μ˜ μž‘μ„±

파일 이름

μ„€λͺ…

top.jsp

ν™”λ©΄ 상단에 ν‘œμ‹œλ  메뉴 파일 이름이닀.

bottom.jsp

ν™”λ©΄ ν•˜λ‹¨μ— ν‘œμ‹œλ  파일 이름이닀.

left.jsp

ν™”λ©΄ μ’ŒμΈ‘μ— ν‘œμ‹œλ  메뉴 파일 이름이닀.

newitem.jsp

μ‹ μƒν’ˆ νŽ˜μ΄μ§€ 파일 이름이닀.

bestitem.jsp

μΈκΈ°μƒν’ˆ νŽ˜μ΄μ§€ 파일 이름이닀.

template.jsp

ν…œν”Œλ¦Ώ νŽ˜μ΄μ§€(λ ˆμ΄μ•„μ›ƒ) 파일 이름이닀.

Login.jsp

둜그인 창이 ν‘œμ‹œλ  파일 이름이닀.

Join.jsp

νšŒμ›κ°€μž… 창이 ν‘œμ‹œλ  파일 이름이닀.

LoginReg.jsp

둜그인 μ„±κ³΅μ‹œ ν‘œμ‹œλ  파일 이름이닀.

JoinReg.jsp

νšŒμ›κ°€μž…μ‹œ ν‘œμ‹œλ  파일 이름이닀.

Logout.jsp

λ‘œκ·Έμ•„μ›ƒμ‹œ ν‘œμ‹œλ  파일 이름이닀.

-Login, Join, LoginReg, JoinReg, Logout은 본인이 직접 λ§Œλ“ κ±°,,

μ„ μƒλ‹˜κ»˜μ„œ μžλ°”μŠ€ν¬λ¦½νŠΈλ‘œ μ“°λŠ” 법을 λ³΄μ—¬μ£Όμ…¨λŠ”λ° μ•žμœΌλ‘œλ„ 계속 λ‚˜μ˜¬κ±°λΌκ³  ν•˜μ…”μ„œ λ”°λ‘œ 적진 μ•Šμ•˜λ‹€.

​

​

top.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%  String id = (String)session.getAttribute("id"); %>

<% if(id == null) {%>
	<a href="template.jsp?page=Login">Login</a>
	<a href="template.jsp?page=Join">Join</a>
<% } else { %>
	<%=id %> λ‹˜ ν™˜μ˜ν•©λ‹ˆλ‹€.
	<a href="logout.jsp">Logout</a>
<% } %>

 

 

left.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    
<center>
<a href="./template.jsp?page=newitem">μ‹ μƒν’ˆ</a><br><br>
<a href="./template.jsp?page=bestitem">μΈκΈ°μƒν’ˆ</a><br><br>
</center>

 

 

bottom.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    
<center>Since 2008</center>

 

 

newitem.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    
<b>μ‹ μƒν’ˆ λͺ©λ‘μž…λ‹ˆλ‹€.</b>

 

 

bestitem.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    
<b>μΈκΈ°μƒν’ˆ λͺ©λ‘μž…λ‹ˆλ‹€.</b>

 

 

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>
	<form action="LoginReg.jsp" method="post">
		아이디 : <input type="text" name="id"><br> 
		λΉ„λ°€λ²ˆν˜Έ : <input type="text" name="passward"><br> 
				<input type="submit" value="둜그인"/>
	</form>
</body>
</html>

 

 

Join.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="JoinReg.jsp" method="post">
		아이디 : <input type="text" name="id"><br> 
		λΉ„λ°€λ²ˆν˜Έ : <input type="text" name="passward"><br> 
		이름 : <input type="text" name="name"><br> 
		μ „ν™”λ²ˆν˜Έ : <input type="text" name="tel"><br>
		<input type="submit" value="νšŒμ› κ°€μž…" />
	</form>
</body>
</html>

 

 

LoginReg.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>
<table>
    <tr>
        <td><%=request.getParameter("id") %>λ‹˜. λ°˜κ°‘μŠ΅λ‹ˆλ‹€!</td>
    </tr>
    <a href="template.jsp?page=Logout">Logout</a>
</table>
</body>
</html>

 

 

JoinReg.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%request.setCharacterEncoding("UTF-8"); %>

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
<table>
    <tr>
        <td><%=request.getParameter("name") %>λ‹˜μ˜ νšŒμ›κ°€μž…μ΄ μ™„λ£Œλ˜μ—ˆμŠ΅λ‹ˆλ‹€!</td>
    </tr>
</table>
</body>
</html>

 

 

Logout.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>
λ‘œκ·Έμ•„μ›ƒλ˜μ—ˆμŠ΅λ‹ˆλ‹€.
</body>
</html>

 

 

template.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%
	String pagefile=request.getParameter("page");
	if (pagefile==null) {pagefile="newitem";}
%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Template Test</title>
<style>
	table {
		margin:auto;
		width:960px;
		color:gray;
		border:1px solid gray;
	}
</style>
</head>
<body>
<table border="1">
	<tr>
		<td height="43" colspan=3 align=left>
			<jsp:include page="top.jsp"/>
		</td>
	</tr>
	<tr>
		<td width="15%" align=right valign=top><br>
			<jsp:include page="left.jsp"/>
		</td>
		<td colspan=2 align=center>
			<jsp:include page='<%=pagefile+".jsp" %>'/>
		</td>
	</tr>
	<tr>
		<td width="100%" height="40" colspan="3">
			<jsp:include page="bottom.jsp"/>
		</td>
	</tr>
</table>
</body>
</html>

 

<μ‹€ν–‰ κ²°κ³Ό>

​

-μ‹ μƒν’ˆ,μΈκΈ°μƒν’ˆ νŽ˜μ΄μ§€

기본값을 "newitem"으둜 μ§€μ •ν–ˆκΈ° λ•Œλ¬Έμ— μ‹ μƒν’ˆ 좜λ ₯ νŽ˜μ΄μ§€κ°€ λœ¬λ‹€.

​

-둜그인, λ‘œκ·Έμ•„μ›ƒ

​

-νšŒμ›κ°€μž…

 

λ°˜μ‘ν˜•

λŒ“κΈ€