성인 미자 판단 jsp입력값 받아서 페이지 간 연결 넘겨주기 - soonbeankim/web1 GitHub Wiki

페이지 2개로 만들기!

<%@ 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>
성인!? 미자?! 
	<br/>
	<br/>
	<br/>
	<form action="age_02.jsp" method="get">
		당신의 나이는 :<input type="text" name="age">
			<input type="submit" value="확인">
			(ex: 17,21,39,68..)

</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>

<%
	int age= Integer.parseInt(request.getParameter("age"));



	if (age<20){
		%>
		<%=age %>살이면, 
		미성년자군요! 
		
<form action="age_01.jsp">
<input type="submit" value="돌아가기" >
</form>
		
<%		
	}else{
		%>
		<%=age %>살이면, 성인이군요!
		<br>마음껏 음주흡연을 즐겨주세요:-)
		
<form action="age_01.jsp">
<input type="submit" value="돌아가기" >
</form>
		
		<% 
	}

	


%>

페이지 3개로 만들기

<%@ 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>
성인!? 미자?! 
	<br/>
	<br/>
	<br/>
	<form action="age_02-1.jsp" method="get">
		당신의 나이는 :<input type="text" name="age">
			<input type="submit" value="확인">
			(ex: 17,21,39,68..)

	</form>


</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>


<%
	int age= Integer.parseInt(request.getParameter("age"));
	String adult="%EC%84%B1%EC%9D%B8";
	String adole="%EB%AF%B8%EC%9E%90";
	
	if (age<20){
		response.sendRedirect("age_02-2.jsp?age="+age+"&adult="+adole);
		
		
	}else{
		response.sendRedirect("age_02-2.jsp?age="+age+"&adult="+adult);
		
	}

%>



</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>

<%-- <%
	int age= Integer.parseInt(request.getParameter("age"));



	if (age<20){
		%>
		<%=age %>살이면, 
		미성년자군요! 
		
<form action="age_01.jsp">
<input type="submit" value="돌아가기" >
</form>
		
<%		
	}else{
		%>
		<%=age %>살이면, 성인이군요!
		<br>마음껏 음주흡연을 즐겨주세요:-)
		
<form action="age_01.jsp">
<input type="submit" value="돌아가기" >
</form>
		
		<% 
	}

	


%> --%>

<%
int age= Integer.parseInt(request.getParameter("age"));
String adult=request.getParameter("adult");

/* out.println(age+adult); */


%>

당신은<%=age %>살 <%=adult %>입니다 




</body>
</html>
⚠️ **GitHub.com Fallback** ⚠️