berryberrybin / kosta-jsp

jsp study
0 stars 0 forks source link

해당 혈액형 Page로 이동 #3

Open berryberrybin opened 2 years ago

berryberrybin commented 2 years ago
image
berryberrybin commented 2 years ago

bloodForm.html

image

<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
<h2> 혈액형 별 유형 알아보기 - get 방식 </h2>

<form name="f" action="bloodPro.jsp" method="get">
  이름 : <input type="text" name="name"> <p/>
  혈액형 : 
     <input type="radio" name="blood" value="A"/> A형
     <input type="radio" name="blood" value="AB"/> AB형
     <input type="radio" name="blood" value="O"/> O형
     <input type="radio" name="blood" value="B"/> B형 <p/>

    <input type="submit" value="결과보기" />
    <input type="reset" value="취소" />
</form>

<hr color="red">

<h2> 혈액형 별 유형 알아보기 - post 방식 </h2>

<form name="f" action="bloodPro.jsp" method="post">
    이름 : <input type="text" name="name"> <p/>
    혈액형 :
    <input type="radio" name="blood" value="A"/> A형
    <input type="radio" name="blood" value="AB"/> AB형
    <input type="radio" name="blood" value="O"/> O형
    <input type="radio" name="blood" value="B"/> B형 <p/>

    <input type="submit" value="결과보기" />
    <input type="reset" value="취소" />
</form>

</body>
</html>
berryberrybin commented 2 years ago

bloodPro.jsp

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

<head>
    <meta charset="UTF-8">
    <title>Document</title>
</head>
<body>
<%
    String blood = request.getParameter("blood");
    out.print(blood); // A, B, AB, O 혈액형이 출력됨
%>
<jsp:forward page='<%=blood+".jsp"%>'/>
</body>
</html>

A.jsp

<body>
<%
    String name = request.getParameter("name");
    String blood = request.getParameter("blood");
    String type = "성격이 ~~~~ 하다. 좋아하는 것은 ~~ 이다.";
%>
<h1> <%=blood%>형 페이지 입니다. </h1>
<h3>
    <%=request.getParameter("name")%>님의 혈액형은 <%=blood%> 입니다.<br>
    <%=blood%> 형의 혈액형 특징 : <%=type%>
</h3>
</body>