본문 바로가기
IT/JSP

Forward Action 연습 1

by dya0 2019. 5. 14.

forwardActionTest1.jsp 입력 화면 구현

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
<%@ page language="java" contentType="text/html; charset=EUC-KR"
    pageEncoding="EUC-KR"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="EUC-KR">
<title>포워드 액션 테스트</title>
<style>
body{
margin:0 auto;
text-align:center;}
form {
    background: green;
    height: 100%;
    color: white;
    text-align: center;
}
table{text-align:center;}
</style>
</head>
<body>
    <form action="forwardTest2.jsp" method="post">
        <table>
            <tr>
                <td>이름</td>
                <td><input type="text" name="name" required></td>
            </tr>
            <tr>
                <td>나이</td>
                <td><input type="text" name="age" required></td>
            </tr>
            <tr>
                <td>주소</td>
                <td><input type="text" name="address" required></td>
            </tr>
            <tr>
                <td colspan="2"><input type="submit" value="전송"></td>
            </tr>
        </table>
    </form>
</body>
</html>
Colored by Color Scripter

forwardActionTest2.jsp

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
<%@ page language="java" contentType="text/html; charset=EUC-KR"
    pageEncoding="EUC-KR"%>
    <% request.setCharacterEncoding("euc-kr"); %>
    
<!DOCTYPE html>
<html>
<head>
<meta charset="EUC-KR">
<title>Insert title here</title>
</head>
<body>
<jsp:forward page="forwardTest3.jsp">
    <jsp:param name = "tel" value = "010-1234-5678"/>
    <jsp:param value="사랑이" name="alias"/>
</jsp:forward>
<%="저는 출력이 될까요?" %>
</body>
</html>
Colored by Color Scripter

 

forwardActionTest3.jsp

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<%@page import="java.util.Enumeration"%>
<%@ page language="java" contentType="text/html; charset=EUC-KR"
    pageEncoding="EUC-KR"%>
<%
    request.setCharacterEncoding("euc-kr");
%>
 
<!DOCTYPE html>
<html>
<head>
<style>form{margin:0 auto;}
table {text-align:center;}
tr>td:first-child{background-color:orange;text-align:center;width:200px;height:50px;}
tr>td:last-child{background-color:yellow;text-align:center;width:350px;}
</style>
<meta charset="EUC-KR">
<title>forwradTest3</title>
</head>
<body>
    <h1>forwardTest3.jsp</h1>
    <form>
    <table>
    <%
    Enumeration<String> e = request.getParameterNames();
    while(e.hasMoreElements()){
        String attributeName = e.nextElement();
        String attributeValue = request.getParameter(attributeName);
    %>
    <tr>
    <td><%=attributeName %></td>
    <td><%=attributeValue %></td>
    </tr>
    <%%>
        </table>
    </form>
</body>
</html>
Colored by Color Scripter

====================결과화면==============================

'IT > JSP' 카테고리의 다른 글

[JSP]include로 화면 구현하기  (0) 2019.05.14
[JSP]include를 이용한 액션 테스트  (0) 2019.05.14
액션 태그  (0) 2019.05.14
Error page 관리  (0) 2019.05.13
Exception  (0) 2019.05.13