JSP/day36 / 23.10.23(월) / (핀테크) Spring 및 Ai 기반 핀테크 프로젝트 구축

허니몬·2023년 10월 23일
0
post-thumbnail

xml 파일 생성하기

프로젝트 우클릭

04_JSP


ex06.jsp






<!-- ex06.jsp -->

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>ex06</title>
</head>
<body>
	<h1>전화번호 입력</h1>
	<br/>
	<form action="ex06Pro.jsp" method="get">
		<label>이름 : </label><input type="text" name="name"/>
		<br/><br/>
		<label>통신사</label>
		<select name="telecom">
			<option value="skt">SKT</option>
			<option value="kt">KT</option>
			<option value="lg">U+</option>
		</select>
		<br/><br/>
		<label>전화번호 : </label><input type="text" name="tel"/>
		<br/><br/>
		<input type="submit" value="제출"/> &nbsp; <input type="reset" value="취소"/>
	</form>
</body>
</html>

ex06Pro.jsp






<!-- ex06Pro.jsp -->

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<% 
request.setCharacterEncoding("utf-8");
String name = request.getParameter("name");
String telecom = request.getParameter("telecom");
String tel = request.getParameter("tel");
%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>ex06Pro</title>
<style type="text/css">
p {
	font-size: 24px;
}
</style>
</head>
<body>
	<h1>확 인</h1>
	<p><%=name %>님의 전화번호 : <%=tel %></p>
	<p>통신사 : <%=telecom %></p>
</body>
</html>

ex07.jsp


<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>ex07</title>
</head>
<body>
	<h1>간단 계산기</h1>
    <br>
    <form action="ex07Pro.jsp" method="post">
        <input type="text" name="dataA">
        <select name="opt">
            <option value="+"> + </option>
            <option value="-"> - </option>
            <option value="*"> * </option>
            <option value="/"> / </option>
        </select>
        <input type="text" name="dataB">
        <br><br>
        <input type="submit" value="계산">
    </form>
</body>
</html>

ex07Pro.jsp


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

double dataA = Double.parseDouble(request.getParameter("dataA"));
double dataB = Double.parseDouble(request.getParameter("dataB"));
String opt = request.getParameter("opt");

double result = 0;
switch(opt){
case "+":
	result = dataA + dataB;
	break;
case "-":
	result = dataA - dataB;
	break;
case "*":
	result = dataA * dataB;
	break;
case "/":
	result = dataA / dataB;
	break;
} 
%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>ex07Pro</title>
</head>
<body>
	<h1>결 과</h1>
	<br>
	<p><%=dataA%> <%=opt %> <%= dataB %> = <%=result %></p>
</body>
</html>

ex08.jsp


<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%
	int dan = 5;
	
%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>ex08</title>
</head>
<body>
	<h1><%=dan %></h1>
	<div>
	<!-- 자바코드안에 태그를 사용할 때에는 끊어서 사용할 것 -->
		<%for(int i=1; i<=9;i++){ %>
			<p><%=dan %> * <%=i %> = <%=dan*i %></p>
		<%}%>
	</div>
</body>
</html>

ex09_Quiz-99dan.jsp


<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>ex09_Quiz-99dan</title>
</head>
<style>
table, tr, td{
	border-collapse: collapse;
	text-align : center;
}
tr, td {
	width: 100px
}
</style>
<body>
	<h1>99</h1>
	<table border=1px>
		<tr>
			<%for(int i=2;i<=9;i++){ %>
				<th><%=i %></th>
			<% }%>
		</tr>
		<tr>
			<%for(int i=1; i<=9 ; i++){ 
				for(int j=2; j<=9; j++){%>
					<td><%=j %> * <%=i %> = <%=j*i %></td>		
				<% } %>
				<tr>
			<% }%> 
	</table>
</body>
</html>

ex09_Quiz-gugudan.jsp


<!-- ex09_Quiz-gugudan.jsp -->

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>ex09_Quiz-gugudan</title>
<!--  
	# QuizGugudan.png 파일의 내용을 구현하세요
-->
</head>
<body>
	<h1>구구단</h1>
	<br/>
	<table border="1">
		<%for(int su=1 ; su<=9 ; su++) {%>
			<tr>
				<%for(int dan=2 ; dan<=9 ; dan++) {%>
					<td><%=dan %> * <%=su %> = <%=dan*su %></td>
				<%} %>
			</tr>
		<%} %>
	</table>
</body>
</html>

05_ImplicitObject


JSP_내장객체.txt

< JSP_내장객체.txt >

JSP 내장 객체 ( Implicit Object )

  • 웹 컨테이너는 JSP 페이지에서 9개의 객체를 생성없이 바로 사용할 수 있도록 제공
  • request : 웹 브라우저의 요청 정보를 저장하고 있는 객체
  • response : 웹 브라우저의 요청에 대한 응답 정보를 저장하고 있는 객체
  • out : JSP 페이지에서 출력할 내용을 갖고 있는 객체
  • session : 하나의 웹 브라우저 내에서 정보를 유지하기 위한 세션 정보를 저장하고 있는 객체
  • application : 웹 애플리케이션 context 정보를 저장하고 있는 객체
  • pageContext : JSP 페이지에 대한 정보를 저장하고 있는 객체
  • page : JSP 페이지를 구현한 Java Class 객체
  • config : JSP 페이지에 대한 설정 정보를 저장하고 있는 객체
  • exception : JSP 페이지에서 예외가 발생한 경우에 사용되는 객체

속성 처리 메서드

  • request, session, application, pageContext 내장 객체는 속성값을 저장하고 읽을 수 있는
    setAttribute(), getAttribute() 메서드를 제공

    setAttribute( String key, Object value ) : void

    • 속성값을 설정하는 메서드
    getAttributeNames() : java.util.Enumeration
    • 내장 객체의 모든 속성명을 읽어오는 메서드

      getAttribute( String key ) : Object

    • 내장 객체의 속성값을 읽어오는 메서드

      removeAttribute( String key ) : void

    • 내장 객체의 속성을 제거하는 메서드

내장 객체의 영역

  • page < request < session < application

ex01_request.jsp


<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>ex01_request</title>
</head>
<body>
	<h1>정보 입력</h1>
	<br>
	<form action="ex01_requestPro.jsp" method="post" autocomplete="off">
		학 번 : <input type="text" name="stuNumber">
		<br><br>
		이 름 : <input type="text" name="name">
		<br><br>
		학 년 : <input type="radio" name="grade" value="1학년"> 1학년
				<input type="radio" name="grade" value="2학년"> 2학년
				<input type="radio" name="grade" value="3학년"> 3학년
				<input type="radio" name="grade" value="4학년"> 4학년
		<br><br>
		과 목 : <select name="subject">
					<option value="java"> Java</option>
					<option value="jsp"> JSP</option>
					<option value="spring"> Spring</option>
				</select>
		<br><br>
		<input type="submit" value="입력 완료">
	</form>
</body>
</html>

ex01_requestPro.jsp


<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<% 
request.setCharacterEncoding("UTF-8");
String stuNumber = request.getParameter("stuNumber");
String name = request.getParameter("name");
String grade = request.getParameter("grade");
String subject = request.getParameter("subject");
%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>ex01_requestPro</title>
<style type="text/css">
table {
	border-collapse: collapse;
	width: 200px;
	text-align: center;
}
</style>
</head>
<body>
	<h1>입력 정보</h1>
	<table border="1">
		<tr>
			<td> 학 번 </td><td><%= stuNumber%></td>
		</tr>
		<tr>
			<td> 이 름 </td><td><%= name%></td>
		</tr>
		<tr>
			<td> 학 년 </td><td><%= grade%></td>
		</tr>
		<tr>
			<td> 과 목 </td><td><%= subject%></td>
		</tr>
	</table>
	<hr>
	<h2>request 정보</h2>
	<p>클라이언트 IP : <%=request.getRemoteAddr() %></p> <!-- v4 형태 -->
	<p>인코딩 방식 : <%=request.getCharacterEncoding() %></p> 
	<p>서버 이름 : <%=request.getServerName() %></p> 
</body>
</html>

ex02_out.jsp


<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>ex02_out</title>
</head>
<body>
	<h1>out 내장 객체</h1>
	<p>
	<% 
		String message = "건강 관리 잘 하세요..";
		out.println(message);
	%>
	</p>
	<p>표현식을 사용한 것과 동일한 결과</p>
	<p><%= message %></p>
</body>
</html>

ex03_application.jsp


<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>ex03_application</title>
</head>
<body>
	<h1>application 내장 객체</h1>
	<%
		String info = application.getServerInfo();
		String path = application.getRealPath("/");
	%>
	<p>웹 컨테이너의 이름, 버전 : <%=info %></p>
	<p>웹 어플리케이션 폴더의 경로 : <%=path %></p>
</body>
</html>

사용중인 서버 관리


우클릭


src - main - webapp - move

start.jsp


<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>start</title>
</head>
<body>
	<h1>페이지 이동</h1>
	<br>
	<div>
		<h2>redirect</h2>
		<p>start.jsp -> sendProc.jsp -> sendResult.jsp 페이지로 이동</p>
		<p>snedRedirect 로 이동하면 데이터는 공유되 않는다</p>
		<p>주소는 sendResult.jsp 가 보임</p>
	</div>
	<input type="button" value="sendRedirect" onclick="location.href='sendProc.jsp'">
	<br><br>
	<div>
		<h2>forward</h2>
		<p>start.jsp -> forwardProc.jsp -> forwardResult.jsp 페이지로 이동</p>
		<p>forward 로 이동하면 데이터는 공유 됨</p>
		<p>주소는 forwardProc.jsp 로 보이지만, 결과는 forwardResult.jsp 가 나옴</p>
	</div>
	<input type="button" value="foward" onclick="location.href='forwardProc.jsp'">
	
	
</body>
</html>

sendProc.jsp


<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<% 
request.setAttribute("add", "데이터 추가");
// 페이지 이동
response.sendRedirect("sendResult.jsp");
%>

sendResult.jsp


<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<% 
String add = (String)request.getAttribute("add");
%>
<html>
<head>
<meta charset="UTF-8">
<title>sendResult</title>
</head>
<body>
	<h1>결과 : <%=add %></h1>
</body>
</html>

forwardProc.jsp


<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%  
request.setAttribute("add", "데이터 추가");
//페이지 이동
// 아래의 객체에 forward 로 이동하는 메서드가 있음 
RequestDispatcher dispatcher = request.getRequestDispatcher("forwardResult.jsp");
dispatcher.forward(request, response);
%>

forwardResult.jsp


<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<% 
String add = (String)request.getAttribute("add");
%>
<html>
<head>
<meta charset="UTF-8">
<title>sendResult</title>
</head>
<body>
	<h1>결과 : <%=add %></h1>
</body>
</html>

06_Action


01_include


ex01_includeForm.jsp


<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>ex01_includeForm</title>
</head>
<body>
	<h1>include</h1>
	<form action="ex01_include.jsp" method="post">
		이름 : <input type="text" name="name">
		<br><br>
		페이지 이름 : <input type="text" name="pageName" value="ex01_includeTest">
		<br><br>
		<input type="submit" value="완료">
	</form>
</body>
</html>

ex01_includeTest.jsp


<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<% 
String name = request.getParameter("name");
%>
포함되는 페이지 ex01_includeTest.jsp입니다.
<br>
<strong><%=name %></strong>님 안녕하세요 <br>
<hr>

ex01_include.jsp


jsp 주석은 아래와 같이 <%-- --%> 로 해야함

안그럼 에러

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%-- 
	# include 액션 태그
	- 다른 페이지의 실행 결과를 현재 페이지에 포함시킨다.
	<jsp:include page="포함될 페이지"/>
--%>
<% 
request.setCharacterEncoding("UTF-8");
String pageName = request.getParameter("pageName");
pageName += ".jsp";
%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>ex01_include</title>
</head>
<body>
	ex01_include.jsp 페이지 입니다.
	<hr>
	<br>
	<jsp:include page="<%=pageName%>"/>
	<br>
	ex01_include.jsp 페이지 마지막 입니다.
	
</body>
</html>

ex02_include.jsp


<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>ex02_include</title>
</head>
<body>
	<h1>include, param</h1>
	<form action="ex02_includeTag.jsp" method="post">
		사이트 이름 : <input type="text" name="siteName" value="ex02_includeTop.jsp">
		<br><br>
		<input type="submit" value="보내기">
	</form>
</body>
</html>

ex02_includeTag.jsp


<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%-- 
	# include 액션 태그에서 포함되는 페이지에 값 전달하기
	- 포함되는 jsp 페이지에 값 전달은 요청 파라미터를 추가적으로 저장해야 함
	  include 액션 태그의 body 안에 param 액션 태그를 사용
	  <jsp:include page="">
	  	<jsp:param name="" value=""/>
	  </jsp:include>
--%>
<%
request.setCharacterEncoding("UTF-8");
String site = request.getParameter("siteName");
%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>ex02_includeTag</title>
</head>
<body>
	<h1>param 액션 태그</h1>
	<jsp:include page="ex02_includeTop.jsp">
		<jsp:param name="site" value="<%=site %>" />
	</jsp:include>
	<br>
	<p>includeTag.jsp  body 입니다</p>
	<strong><%=site %></strong>
</body>
</html>

ex02_includeTop.jsp


<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<% 
String site = request.getParameter("site");
%>
includeTop.jsp 입니다
<br>
<%=site %>

02_forward


ex01_forward.jsp


<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>ex01_forward</title>
</head>
<body>
	<h1>forwardForm</h1>
	<form action="ex01_forwardTest.jsp" method="post">
		아이디 : <input type="text" name="id">
		<br><br>
		취  미 : <select name="hobby">
					 <option value="game"> 게  임 </option>	
					 <option value="study"> 공  부 </option>	
					 <option value="muisic"> 음악감상</option>	
				 </select>
		<br><br>
		<input type="submit" value="완료">		
	</form>
</body>
</html>

ex01_forwardTest.jsp


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

ex01_forwardTo.jsp


<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<% 
String id = request.getParameter("id");
String hobby = request.getParameter("hobby");
%>    
<%-- 
	ex01_forwardTest 에서 forward 를 했기 때문에 
	해당 파일에서 ex01_forward.jsp 에서 넘긴 데이터를 사용 가능 
--%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>ex01_forwardTo</title>
</head>
<body>
	<h1>forwardTo</h1>
	<br>
	<p>포워딩되는 페이지 ex01_forwardTo.jsp 입니다</p>
	<p><strong><%=id %></strong>님의 취미 : <%=hobby %> </p>
</body>
</html>

bloodResult.jsp


<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>bloodForm</title>
<!-- 
	각 혈액형에 대한 페이지를 추가하고, 'bloodResult.jsp' 에서
	선택한 혈액형의 페이지가 표시되도록 구현 
-->
</head>
<body>
	<h1>혈액형별 성격</h1>
	<p>혈액형을 선택하세요</p>
	<form action="bloodResult.jsp" method="post">
		이름 : <input type="text" name="name"><br>
		<input type="radio" name="bloodType" value="A"> A형
		<br>
		<input type="radio" name="bloodType" value="B"> B형
		<br>
		<input type="radio" name="bloodType" value="O"> O형
		<br>
		<input type="radio" name="bloodType" value="AB"> AB형
		<br><br>
		<input type="submit" value="확인">
		
	</form>
</body>
</html>

bloodResult.jsp


<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%
request.setCharacterEncoding("utf-8");
String name = request.getParameter("name");
String bloodType = request.getParameter("bloodType");
String bloodSite = "blood" + bloodType + ".jsp";
%>
<jsp:forward page="<%=bloodSite %>">
	<jsp:param value="<%=name %>" name="name"/>
</jsp:forward>

bloodResultT.jsp



<!-- 02_forward/bloodResult.jsp -->

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%
String name = "test";
String bloodType = request.getParameter("bloodType");
bloodType += ".jsp";
%>
<jsp:forward page="<%=bloodType %>">
	<jsp:param value="<%=name %>" name="name"/>
</jsp:forward>

03_javabeans


beanTestForm.jsp


<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>beanTestForm</title>
</head>
<body>
	<h1>이름을 입력하세요</h1>
	<br>
	<form action="beanTestPro.jsp" method="post">
		이 름 : <input type="text" name="name">
		<br><br>
		<input type="submit" value="전송">
	</form>
</body>
</html>

TestBeanDTO.java

src/main/java/test.bean


package test.bean;

public class TestBeanDTO {
	private String beanName;
	
	public TestBeanDTO() {
		super();
	}

	public TestBeanDTO(String beanName) {
		this.beanName = beanName;
	}

	public String getBeanName() {
		return beanName;
	}

	public void setBeanName(String beanName) {
		this.beanName = beanName;
	}
}

beanTestPro.jsp


<%@page import="test.bean.TestBeanDTO"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<% 
request.setCharacterEncoding("utf-8");
String name = request.getParameter("name");

TestBeanDTO dtoA = new TestBeanDTO(name); 

%>
<%-- 
	# javabeans
	- 데이터를 저장하기 위한 변수(속성), getter/setter 메서드로만 이루어진 class
	
	# useBean : javabeans 객체 생성, 설정
	- <jsp:uesBean id="빈 이름" class="javabean 클래스 이름" scope=""/>
	  * id    : 생성될 javabean 객체(instance) 이름
	    class : 객체 생성에 사용되는 javabean 클래스명. package명까지 다 들어와야 함
	    >> ex)test.bean.TestBeanDTO
	    scope : javabean 객체가 공유되는 유효범위 지정( page(default), request, session, application )
	
	# setProperty : 프로퍼티(bean의 멤버필드) 값 설정
	- <jsp:setProperty name="빈 이름(useBean의 id)" property="프로퍼티 이름" value="프로퍼티에 저장할 값"/>
	  * name     : 자바빈 객체 이름
	    property : 프로퍼티 명
	    value    : 프로퍼티에 저장하는 값 - 생략 가능
	    
	# getProperty : 프로퍼티 값 가져오기
	- <jsp:getProperty name="빈 이름" property="프로퍼티 이름"/>
	  * name     : 자바빈 객체 이름
	    property : 프로퍼티 명    
--%>
<%-- 위의 new를 통해 객체를 생성한 것과 동일 함 --%>
<jsp:useBean id="dtoB" class="test.bean.TestBeanDTO"><!-- new -->
	<jsp:setProperty name="dtoB" property="beanName" value="<%=name %>"/> <!-- setter() -->
</jsp:useBean>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>beanTestPro</title>
</head>
<body>
	<h1>javabeans test</h1>
	<br>
	<p>입력한 이름 : <%=name %></p>
	<br>
	<p>dtoA 이름 : <%=dtoA.getBeanName() %></p>
	<p>dtoB 이름(getter) : <%=dtoB.getBeanName() %></p>
	<p>dtoB 이름(jsp:getProperty) : <jsp:getProperty name="dtoB" property="beanName"/></p> <!-- getter() -->

</body>
</html>

personForm.jsp


<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>personForm</title>
<!-- # 아래의 입력값을 사용해서 'personPro.jsp' 에서 personDTO class 객체를 생성하여 결과 출력 
	 - package : com.test
	 - jsp 액션 태그 사용
-->
</head>
<body>
	<h1>정보 입력</h1>
	<form action="personPro.jsp" method="post">
		이 름 : <input type="text" name="name"/>
		<br><br>
		나 이 : <input type="text" name="age"/>
		<br><br>
		<input type="submit" value="전송"/>
	</form>
</body>
</html>

com.test/personDTO.java


package com.test;

public class personDTO {
	private String name;
	private int age;

	public personDTO() {
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	public int getAge() {
		return age;
	}
	public void setAge(int age) {
		this.age = age;
	}
}

personPro.jsp


<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%
request.setCharacterEncoding("utf-8");
String name = request.getParameter("name");
int age = Integer.parseInt(request.getParameter("age"));
%>
<jsp:useBean id="manA" class="com.test.personDTO">
	<jsp:setProperty name="manA" property="name" value="<%=name %>"/>
	<jsp:setProperty name="manA" property="age" value="<%=age %>"/>
</jsp:useBean>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>personPro</title>
</head>
<body>
	<h1>확 인</h1>
	<br>
	<p>이름 : <strong><jsp:getProperty name="manA" property="name"/></strong></p>
	<p>나이 : <strong><jsp:getProperty name="manA" property="age"/></strong></p>
</body>
</html>
profile
Fintech

0개의 댓글