1. loggin_Page.html

<!DOCTYPE html>
<html>
<head>
<meta charset="EUC-KR">
<title>TITLE</title>
</head>
<body>
	<form name="loggin_page" method="post" action="loggin.jsp">
		id : <input type="text" name="id"/><br/>
		password : <input type="text" name="password"/><br/>
		<button>로그인</button>
	</form>	
	<button  onclick="location.href='reg_page.html'">회원가입</button>
</body>
</html>

 

2. reg_page.html

<!DOCTYPE html>
<html>
<head>
<meta charset="EUC-KR">
<title>회원가입 페이지</title>

<script>
	function check_form() 
	{
		var id = document.reg_form.id.value ;
		if(id == null || id.length < 4) 
		{
			alert('아이디는 4자 이상이어야 한다!');
			return false;
		}
		return true;
	}
</script>
</head>
<body>

	<form name="reg_form" method="post" action="reg_page.jsp" onSubmit="return check_form()">
		id : <input type="text" name="id"/><br/>
		password : <input type="text" name="password"/><br/>
		password check : <input type="text" name="password1"/><br/>
		<input type="submit" value="회원가입">
	</form>

</body>
</html>

>자바스크립트 <script></script>

 >> var id = document.reg_form.id.value;

 

자바스크립트에서 document 제타위키 내용 

  • 웹브라우저가 HTML 문서를 적재하면 document 객체가 됨
  • HTML 태그들 중 최상위 노드
  • 다른 모든 노드(태그)들의 소유자

>alert 오타 주의하기

>onclick >> 클릭하면

>location.href >> reg_page.html로 이동한다는 의미

 

 

3. loggin.jsp

<%@ page language="java" contentType="text/html; charset=EUC-KR"
    pageEncoding="EUC-KR"%>
    
<%
	request.setCharacterEncoding("euc-kr");
	String id = request.getParameter("id");
	String password = request.getParameter("password");
	
%>
<!DOCTYPE html>
<html>
<head>
<meta charset="EUC-KR">
<title>Insert title here</title>
</head>
<body>
	<%= id %>님! 환영합니다!<br/>	
</body>
</html>

4. reg_page.jsp

<%@ page language="java" contentType="text/html; charset=EUC-KR"
    pageEncoding="EUC-KR"%>
    
<%
	request.setCharacterEncoding("euc-kr");
	String id = request.getParameter("id");
	String password = request.getParameter("password");
	
%>
<!DOCTYPE html>
<html>
<head>
<meta charset="EUC-KR">
<title>Insert title here</title>
</head>
<body>
	<%= id %>님! 환영합니다!<br/>
</body>
</html>

 

 

데이터 베이스와 연동한것이 아니기때문에 로그인도 아무거나 쳐도 로그인되고 가입도 아무거나 쳐도 가입이되는데

html과 jsp사이의 이해를 위한 것이니 동작의 흐름이 중요

 

jsp는 서버에서 결과를 처리해서 보여주는 결과