본문 바로가기

JavaScript/jQuery

제이쿼리, jsp간 연동해보기2

반응형

index.html

<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <title>Insert title here</title>
    <script src="https://code.jquery.com/jquery-3.4.1.min.js"></script>
</head>

<body>
    <h2>송부 정보의 입력</h2>
    <form id="frm" action="NewFile.jsp">
        이 름: <input type="text" name="name" /><br>
        <br> 우편번호: <input type="text" name="mail1">-<input type="text" name="mail2"> <button>주소
      변환</button>
        <br>
        <br> 주소 <input type="text" name="address"><br>
        <br>전화번호 <input type="text" name="phone1">-<input type="text" name="phone2">-<input type="text" name="phone3"><br>
        <br><br>
        <select name="select">
      <option value="지정하지 않음">지정하지 않음</option>
      <option value="10:00 ~12:00">10:00 ~12:00</option>
      <option value="12:00 ~13:00">12:00 ~13:00</option>
      <option value="15:00 ~17:00">15:00 ~17:00</option>
      <option value="17:00 ~20:00">17:00 ~20:00</option>
    </select>
        <br><br>
        <br> 영수증요청: <input type="checkbox" name="bill" value="요청">
        <br>
        <br> 메일 매거진을 수신 <input type="radio" name="mailReceive" value="신청">신청 <input type="radio" name="mailReceive" value="신청하지 않음">신청하지않음
        <br><br>
        <button id="submit">확인화면으로진행</button>

    </form>
    </select>
    <script>
        $(function() {
            $("#submit").on("click", function() {
                $("#frm").submit();
            })
            $("input").focus(
                function() {
                    $(this).css("background-color", "#ffff00");
                }
            );

            $("input").blur(function() {
                $(this).css("background-color", "#fff");
            });
        })
    </script>
</body>

</html>

 

NewFile.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>
</head>
<body>
	<%
		String name = request.getParameter("name");
		out.println("name:" + name);
		String mail1 = request.getParameter("mail1");
		String mail2 = request.getParameter("mail2");
		out.println("우편번호: " + mail1 + " - " + mail2);
		String phone1 = request.getParameter("phone1");
		String phone2 = request.getParameter("phone2");
		String phone3 = request.getParameter("phone3");
		out.println("우편번호: " + phone1 + " - " + phone2 + " - " + phone3);
		String select = request.getParameter("select");
		out.println("배달시간: " + select);
		String bill = request.getParameter("bill");
		out.println("영수증요청: " + bill);
		String mailReceive = request.getParameter("mailReceive");
		out.println("메일 매거진을 수신");
	%>

</body>
</html>

http://localhost:8080/work001/NewFile.jsp?name=%EA%B3%A0%EA%B5%AC%EB%A7%88&mail1=123&mail2=123&address=%EC%9A%B0%EB%A6%AC%EC%A7%91&phone1=11&phone2=111&phone3=11&select=15%3A00+%7E17%3A00&bill=%EC%9A%94%EC%B2%AD&mailReceive=%EC%8B%A0%EC%B2%AD

 

 

반응형