회원 정보
- client가 정보를 입력하는 서버
<%@ 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>
<style>
table, th, td{
border : 1px solid black;
border-collapse: collapse;
}
th, td{
padding: 5px 10px;
}
</style>
</head>
<body>
<h1>회원 정보</h1>
<form action="usejs.jsp" method="get">
<table>
<tr>
<th>이름</th>
<td><input type="text" name="userName"/></td>
</tr>
<tr>
<th>성별</th>
<td>
<input type="radio" name="gender" value="남자"/> 남자
<input type="radio" name="gender" value="여자"/> 여자
</td>
</tr>
<tr>
<th>취미</th>
<td>
<input type="checkbox" name="hobby" value="독서"/> 독서
<input type="checkbox" name="hobby" value="게임"/> 게임
<input type="checkbox" name="hobby" value="운동"/> 운동
<input type="checkbox" name="hobby" value="영화"/> 영화
</td>
</tr>
<tr>
<th colspan="2">
<input type="submit" value="전송"/>
</th>
</tr>
</table>
</form>
</body>
</html>
- client가 보낸 정보를 받는 server
<%@ 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>
<p>이름 : <%= request.getParameter("userName") %></p>
<p>성별 : <%= request.getParameter("gender") %></p>
<p>
취미 :
<%
String[] hobby = request.getParameterValues("hobby");
for(int i=0; i<hobby.length; i++){
%>
<%= hobby[i] %>
<%
}
%>
</p>
<hr/>
<h1>그 밖의 내용</h1>
<p>전송 방식 : <%= request.getMethod() %></p>
<p>IP 주소(ipv6) : <%= request.getRemoteAddr() %></p>
<p>요청쿼리 : <%= request.getQueryString() %></p>
<p>요청 URL(link) : <%= request.getRequestURL() %></p>
<p>요청 URI(interface) : <%= request.getRequestURI() %></p>
</body>
</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>
</body>
<script>
var name = '<%=request.getParameter("userName")%>';
var gender = '<%=request.getParameter("gender")%>';
var arr = [];
<%
String[] hobby = request.getParameterValues("hobby");
for(int i=0; i<hobby.length; i++){
%>
arr.push('<%=hobby[i]%>');
<%
}
%>
console.log(name);
console.log(gender);
console.log(arr);
</script>
</html>
회원가입 페이지
- client가 정보를 입력하는 서버
<html>
<head>
<meta charset="UTF-8">
<title>회원가입 페이지</title>
<style>
table, td, th{
border: 1px solid black;
border-collapse: collapse;
}
th, td{
padding : 10px 20px;
}
input[type='text'], input[type='password'], input[type='email'], input[type='range']{
width: 100%;
}
</style>
</head>
<body>
<h1>회원가입 페이지</h1>
<hr/>
<form action="result.jsp" method="get">
<table>
<colgroup>
<col width="30%"/>
<col width="70%"/>
</colgroup>
<thead>
<tr>
<th>아이디</th>
<td><input type="text" name="userId" value=""/></td>
</tr>
<tr>
<th>비밀번호</th>
<td>
<input type="password" name="userPw" value=""/>
</td>
</tr>
<tr>
<th>비밀번호 확인</th>
<td>
<input type="password" name="userPw" value=""/>
</td>
</tr>
<tr>
<th>이 름</th>
<td><input type="text" name="userName" value=""/></td>
</tr>
<tr>
<th>이 메 일</th>
<td><input type="text" name="email" value=""/></td>
</tr>
<tr>
<th>생년월일</th>
<td>
<!--옵션은 지정하지 않으면 가장 윗값이 기본값으로 지정됨-->
<select name="year">
<option value="1996">1996</option>
<option value="1997">1997</option>
<option value="1998">1998</option>
</select>
<select name="month">
<option value="9">9</option>
<option value="10" selected>10</option>
<option value="11">11</option>
</select>
<select name="day">
<option value="1">1</option>
<option value="2">2</option>
<option value="3" selected>3</option>
</select>
</td>
</tr>
<tr>
<th>성 별</th>
<td>
<input type="radio" name="gender" value="남자"/> 남자
<input type="radio" name="gender" value="여자"/> 여자
</td>
</tr>
<tr>
<th>취 미</th>
<td>
<input type="checkbox" name="hobby" value="드라이브"/> 드라이브
<input type="checkbox" name="hobby" value="스포츠"/> 스포츠
<input type="checkbox" name="hobby" value="게임"/> 게임
<input type="checkbox" name="hobby" value="낚시"/> 낚시
</td>
</tr>
<tr>
<th>나 이</th>
<td>
<form>
<input type="number" name="age" min="20" max="40"/>
</form>
</td>
</tr>
<tr>
<th>보안등급</th>
<td>
<input type="range" name="points" value="0" min="0" max="3" step="1"/>
</td>
</tr>
<tr>
<th colspan="2">
<input type="submit" value="회원가입"/>
</th>
</tr>
</thead>
</table>
</form>
</body>
</html>
- client가 보낸 정보를 받는 server
<%@ 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>
<!-- index.html로부터 온 파라메터 값을 여기에 표현하시오 -->
<p>아 이 디 : <%= request.getParameter("userId") %> </p>
<p>비밀번호 : <%= request.getParameter("userPw") %> </p>
<p>이 름 : <%= request.getParameter("userName") %> </p>
<p>이 메 일 : <%= request.getParameter("email") %> </p>
<p>생년월일 :
<%= request.getParameter("year") %>년
<%= request.getParameter("month") %>월
<%= request.getParameter("day") %>일
</p>
<p>성 별 : <%= request.getParameter("gender") %> </p>
<p>취 미 :
<%
String[] hobby = request.getParameterValues("hobby");
for(String h : hobby){
%>
<%= h %>
<%
}
%>
</p>
<p>나 이 : <%= request.getParameter("age") %> </p>
<p>보안등급 : <%= request.getParameter("points") %> </p>
</body>
</html>
'코딩도전기 > JSP' 카테고리의 다른 글
JSP Templates 설정 (0) | 2023.03.02 |
---|---|
CODO Day17_JSP(JSTL태그&함수) (0) | 2023.02.23 |
CODO Day16_JSP(Scope/AtionTag/JavaBean/ElTag/JSTL) (0) | 2023.02.22 |
CODO Day15_JSP(Out/Response/Cookie/Session) (0) | 2023.02.21 |
CODO Day14_Java Servlet(server) Page(Web/WAS/TOMCAT/Scriptlet/내장객체(Request객체)) (0) | 2023.02.20 |