😁 html

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<style>
form{
 border : 1px solid blue;
 padding : 15px;
 width : 50%;
 margin : 5px blue;
} 

.lab{
	display : inline-block; /* 인라인요소의 가로세로 크기 지정하기 위해 사용 */
	width : 70px;
	height : 35px;	
}
 
</style>
</head>
<body>
<form action="formsend3.jsp" method="post">

	<label class = "lab">이름</label>
	<input type="text" name="name"><br>
	
	<label class = "lab">첨부파일</label>
	<input type ="file" name="file"><br>
	<br>
	<label>좋아하는 음식(한국)</label><br>
	<select name="korea" multiple="multiple" size="6">
		<option>떡볶이</option>
		<option selected>김밥</option>
		<option>라면</option>
		<option>돈까스</option>
		<option selected>우동</option>
		<option>오징어찌개</option>
		<option>김치찌개</option>
		<option>된장찌개</option>
	</select>
	<br><br>
	
	<label>좋아하는 음식(양식)</label><br>
	<select name="ameri">
		<option>떡볶이</option>
		<option>김밥</option>
		<option>라면</option>
		<option>돈까스</option>
		<option>우동</option>
		<option selected>오징어찌개</option>
		<option>김치찌개</option>
		<option>된장찌개</option>
	</select>
	<br><br>
	<input type="image" src="../images/check.png" alt="check.png"><br>
	<input type="submit" value="전송">
	<input type="button" value="확인">
	<input type="reset">
	<br><br>
	<button type="button">전송</button>
	<button type="submit">전송</button>
	<button>전송</button>
	
</form>
</body>
</html>

😁 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>
<style type="text/css">
h1{
	color : red;
}
p{
	font-size : 1.5em;
}
table{
	border : 2px solid green;
}
td{
	width : 200px;
	height : 50px;
	text-align : center;
}
</style>
</head>
<body>
<h1>JSP : Java Server Page</h1>
<p>클라이언트 요청(전송)시 데이터를 전달 받아서 처리 하는 서버프로그램 이다</p>
<p>처리결과를 html태그를 이용하여 응답한다</p>

<%
	request.setCharacterEncoding("UTF-8");

	String userName = request.getParameter("name");
	String userFile = request.getParameter("file");
	
	String korea[] = request.getParameterValues("korea");
	
	String res = "";
	for(int i =0; i < korea.length; i++){
		res += korea[i]; 
	}
	
	String ameri = request.getParameter("ameri");
	


%>

<table border ="1">
	<tr>
		<td>이름</td>
		<td><%= userName %></td>
	</tr>
	
	<tr>
		<td>파일</td>
		<td><%= userFile %></td>
	</tr>
	
		<tr>
		<td>좋아하는 음식(korea)</td>
		<td><%= res %></td>
	</tr>
	
		<tr>
		<td>좋아하는 음식(ameri)</td>
		<td><%= ameri %></td>
	</tr>
	
</table>
</body>
</html>

😁 참고자료

 

😁 실행

'웹프로그래밍(HTML, CSS3, JavaScript)' 카테고리의 다른 글

[html/jsp] 의사클래스 상태  (0) 2022.12.27
[HTML/jsp] placeholder, 전화번호  (0) 2022.12.25
[HTML&Script] formtest2  (0) 2022.12.23
[HTML&Script] buttonproc  (0) 2022.12.23
[HTML&Script] formtest  (0) 2022.12.23

+ Recent posts