반응형
<<<액션태그 이어서>>>
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74 |
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"
info="ip나 localhost를 구분하여 다른 언어를 보여주는 일"
%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>디자인</title>
<link rel="stylesheet" type="text/css" href="http://localhost:8080/jsp_prj/common/css/main_v190130.css"/>
<style type="text/css">
/* wrap에 background-color를 넣고 header, container, footer에도 background-color를 넣어 가려지는지 확인 */
#wrap{margin:0px auto; width:800px; height:860px;}
/* wrap안쪽 디자인들은 wrap안에 들어있기 때문에 width안줘도 자동으로 800이 됨 */
#header{width:800px; height:140px; background: #FFFFFF url(http://localhost:8080/jsp_prj/common/images/header_bg.png) repeat-x;
position:relative;}
#headerTitle{ font-family: HY견고딕, 고딕; font-size:35px; font-weight:bold; text-align:center;
position:absolute; top:40px; left:290px;}
#container{width:800px; height:600px;}
#footer{width:800px; height:120px;}
#footerTitle{float:right; font-size:15px; padding-top:20px; padding-right:20px;}
</style>
</head>
<body>
<div id="wrap">
<div id="header">
<div id="headerTitle">SIST Class4 </div>
</div>
<div id="container">
<%
//접속자의 ip를 얻는다.
String ipAddr=request.getRemoteAddr();
String nameLabel="name";
String ageLabel="age";
String addrLabel="address";
String btnLabel="submit";
if("0:0:0:0:0:0:0:1".equals(ipAddr)){//localhost
nameLabel="이름";
ageLabel="나이";
addrLabel="주소";
btnLabel="전송";
}//end if
%>
<form action="forward_b.jsp" method="get">
<table>
<tr>
<td><label><%= nameLabel%></label></td>
<td><input type="text" name="name" class="inputBox"></td>
</tr>
<tr>
<td><label><%= ageLabel%></label></td>
<td><input type="text" name="age" class="inputBox"></td>
</tr>
<tr>
<td><label><%= addrLabel%></label></td>
<td><input type="text" name="address" class="inputBox"></td>
</tr>
<tr>
<td colspan="2" align="center"><input type="submit" value="<%= btnLabel%>" class="btn"></td>
</tr>
</table>
</form>
</div>
<div id="footer">
<div id="footerTitle"> copyright© all right reserved class4 </div>
</div>
</div>
</body>
</html> |
|
|
|
|
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 |
<%@page import="java.util.Date"%>
<%@page import="java.text.SimpleDateFormat"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"
info="localhost또는 ip를 식별하여 다른 언어를 사용하는 페이지로 이동하는 일"
%>
<!--html 내용을 가지지 않고 이동하는 표시만 -->
<!--scriptlet에서는 javacode만 가능 -->
<%
request.setCharacterEncoding("UTF-8");
String ip=request.getRemoteAddr();
String lang="English";
String url="eng.jsp";
String[]loc={"서울","경기","강원","충청","경상","전라","제주"};
request.setAttribute("loc", loc);
SimpleDateFormat sdf=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
if("0:0:0:0:0:0:0:1".equals(ip)){//한국어 페이지로 이동
url="kor.jsp";
lang="한국어";
}//end if
%>
<%--이 페이지에서 생산한 파라메터가 없을 때
<jsp:forward page="<%=url %>"/> --%>
<!--이 페이지에서 생산할 파라메터가 있을 때 // html주석이 forward tag안으로 들어가면 에러남-->
<jsp:forward page="<%=url %>">
<jsp:param value="<%=lang %>" name="lang"/>
<jsp:param value="<%=sdf.format(new Date()) %>" name="date"/>
</jsp:forward>
<%-- <jsp:forward page="kor.jsp"/>
<% }else{//영어 페이지로 이동%>
<jsp:forward page="eng.jsp"/>
<%
}//end else
%>--%>
|
|
|
|
|
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65 |
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>디자인</title>
<link rel="stylesheet" type="text/css" href="http://localhost:8080/jsp_prj/common/css/main_v190130.css"/>
<style type="text/css">
/* wrap에 background-color를 넣고 header, container, footer에도 background-color를 넣어 가려지는지 확인 */
#wrap{margin:0px auto; width:800px; height:860px;}
/* wrap안쪽 디자인들은 wrap안에 들어있기 때문에 width안줘도 자동으로 800이 됨 */
#header{width:800px; height:140px; background: #FFFFFF url(http://localhost:8080/jsp_prj/common/images/header_bg.png) repeat-x;
position:relative;}
#headerTitle{ font-family: HY견고딕, 고딕; font-size:35px; font-weight:bold; text-align:center;
position:absolute; top:40px; left:290px;}
#container{width:800px; height:600px;}
#footer{width:800px; height:120px;}
#footerTitle{float:right; font-size:15px; padding-top:20px; padding-right:20px;}
</style>
</head>
<body>
<div id="wrap">
<div id="header">
<div id="headerTitle">SIST Class4 </div>
</div>
<div id="container">
<%
//HTML Form Control에서 입력된 값
String name=request.getParameter("name");
String age=request.getParameter("age");
String addr=request.getParameter("address");
//<jsp:param으로 생성된 값
String lang=request.getParameter("lang");
String date=request.getParameter("date");
%>
<strong>안녕하세요? 한국어 페이지 입니다.</strong>
<strong>입력하신 값은 아래와 같습니다.</strong>
<ul>
<li>이름: <strong><%= name %></strong></li>
<li>나이: <strong><%= age %></strong></li>
<li>주소: <strong><%= addr %></strong></li>
<li>사용언어: <strong><%= lang %></strong></li>
<li>접속시간: <strong><%= date %></strong></li>
<li>지역선택:
<select>
<% String[] loc=(String[])request.getAttribute("loc");
for(int i=0; i<loc.length; i++){
%>
<option value="<%=loc[i] %>"><%=loc[i] %></option>
<%
}//end for
%>
</select>
</li>
</ul>
<a href="forward_a.jsp">입력폼으로 이동</a>
</div>
<div id="footer">
<div id="footerTitle"> copyright© all right reserved class4 </div>
</div>
</div>
</body>
</html> |
|
|
|
|
|
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65 |
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>디자인</title>
<link rel="stylesheet" type="text/css" href="http://localhost:8080/jsp_prj/common/css/main_v190130.css"/>
<style type="text/css">
/* wrap에 background-color를 넣고 header, container, footer에도 background-color를 넣어 가려지는지 확인 */
#wrap{margin:0px auto; width:800px; height:860px;}
/* wrap안쪽 디자인들은 wrap안에 들어있기 때문에 width안줘도 자동으로 800이 됨 */
#header{width:800px; height:140px; background: #FFFFFF url(http://localhost:8080/jsp_prj/common/images/header_bg.png) repeat-x;
position:relative;}
#headerTitle{ font-family: HY견고딕, 고딕; font-size:35px; font-weight:bold; text-align:center;
position:absolute; top:40px; left:290px;}
#container{width:800px; height:600px;}
#footer{width:800px; height:120px;}
#footerTitle{float:right; font-size:15px; padding-top:20px; padding-right:20px;}
</style>
</head>
<body>
<div id="wrap">
<div id="header">
<div id="headerTitle">SIST Class4 </div>
</div>
<div id="container">
<%
//HTML Form Control에서 입력된 값
String name=request.getParameter("name");
String age=request.getParameter("age");
String addr=request.getParameter("address");
//<jsp:param으로 생성된 값
String lang=request.getParameter("lang");
String date=request.getParameter("date");
%>
<strong>안녕하세요? 영어 페이지 입니다.</strong>
<strong>입력하신 값은 아래와 같습니다.</strong>
<ul>
<li>이름: <strong><%= name %></strong></li>
<li>나이: <strong><%= age %></strong></li>
<li>주소: <strong><%= addr %></strong></li>
<li>사용언어: <strong><%= lang %></strong></li>
<li>접속시간: <strong><%= date %></strong></li>
<li>지역선택:
<select>
<% String[] loc=(String[])request.getAttribute("loc");
for(int i=0; i<loc.length; i++){
%>
<option value="<%=loc[i] %>"><%=loc[i] %></option>
<%
}//end for
%>
</select>
</li>
</ul>
<a href="forward_a.jsp">입력폼으로 이동</a>
</div>
<div id="footer">
<div id="footerTitle"> copyright© all right reserved class4 </div>
</div>
</div>
</body>
</html> |
|
|
|
|
*<jsp:forward> action tag
-
페이지 이동(Request Dispatcher 사용)
-
데이터처리와 화면디자인을 분리하여 작성할 때
-
파라메터를 생성하지 않고 이동할 때
-
<jsp:forward page="이동할 페이지">
-
파라메터를 생성하여 이동할 때
-
<jsp:forward page="이동할 페이지">
-
<jsp:param name="파라메터명" value="파라메터 값"> => jsp에서 <jsp:param>을 받을 때에는 request.getParameter("이름");
-
</jsp:forward>
(이미지)
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60 |
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"
%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>디자인</title>
<link rel="stylesheet" type="text/css" href="http://localhost:8080/jsp_prj/common/css/main_v190130.css"/>
<style type="text/css">
/* wrap에 background-color를 넣고 header, container, footer에도 background-color를 넣어 가려지는지 확인 */
#wrap{margin:0px auto; width:800px; height:860px;}
/* wrap안쪽 디자인들은 wrap안에 들어있기 때문에 width안줘도 자동으로 800이 됨 */
#header{width:800px; height:140px; background: #FFFFFF url(http://localhost:8080/jsp_prj/common/images/header_bg.png) repeat-x;
position:relative;}
#headerTitle{ font-family: HY견고딕, 고딕; font-size:35px; font-weight:bold; text-align:center;
position:absolute; top:40px; left:290px;}
#container{width:800px; height:600px;}
#footer{width:800px; height:120px;}
#footerTitle{float:right; font-size:15px; padding-top:20px; padding-right:20px;}
</style>
</head>
<body>
<div id="wrap">
<div id="header">
<div id="headerTitle">SIST Class4 </div>
</div>
<div id="container">
<!--객체 생성 -->
<!--<%@ page import="day0313.TestVO" %> import해도 아래 class명에 TestVO만 쓰면 에러남 -->
<jsp:useBean id="t_vo" class="day0313.TestVO" scope="page"/>
<!--setter호출 : set을 제외한 method명을 set을 제외한 소문자로 시작되게 호출 -->
<jsp:setProperty property="firstName" name="t_vo" value="노진경"/>
<jsp:setProperty property="age" name="t_vo" value="20"/>
<!--getter호출: get을 제외한 method명을 소문자로 기술
Expression을 사용하지 않아도 화면 출력이 된다.
-->
이름 : <jsp:getProperty property="firstName" name="t_vo"/><br/>
나이 : <jsp:getProperty property="age" name="t_vo"/><br/>
<%
//<jsp:useBean으로 생성된 객체는 자바코드로 접근하여 사용할 수 있다.
//setter 호출
t_vo.setFirstName("정윤");
t_vo.setAge(30);
%>
<!--getter호출 -->
<div>
재설정 이름: <%=t_vo.getFirstName() %><br/>
재설정 나이: <%=t_vo.getAge() %><br/>
</div>
</div>
<div id="footer">
<div id="footerTitle"> copyright© all right reserved class4 </div>
</div>
</div>
</body>
</html> |
|
|
|
|
|
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 |
package day0313;
public class TestVO {
private String firstName;
private int age;
//기본생성자 주석처리해도 컴파일러가 생성해줌
public TestVO() {
System.out.println("TestVO의 기본 생성자");
}
//생성자가 하나라도 만들어져있으면 컴파일러가 자동으로 생성할 수 없어서 에러
public TestVO(String firstName, int age) {
this.firstName = firstName;
this.age = age;
System.out.println("TestVO의 인자있는 생성자");
}
public String getFirstName() {
return firstName;
}
public int getAge() {
return age;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
public void setAge(int age) {
this.age = age;
}
}//class
|
|
|
|
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62 |
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>디자인</title>
<link rel="stylesheet" type="text/css" href="http://localhost:8080/jsp_prj/common/css/main_v190130.css"/>
<style type="text/css">
/* wrap에 background-color를 넣고 header, container, footer에도 background-color를 넣어 가려지는지 확인 */
#wrap{margin:0px auto; width:800px; height:860px;}
/* wrap안쪽 디자인들은 wrap안에 들어있기 때문에 width안줘도 자동으로 800이 됨 */
#header{width:800px; height:140px; background: #FFFFFF url(http://localhost:8080/jsp_prj/common/images/header_bg.png) repeat-x;
position:relative;}
#headerTitle{ font-family: HY견고딕, 고딕; font-size:35px; font-weight:bold; text-align:center;
position:absolute; top:40px; left:290px;}
#container{width:800px; height:600px;}
#footer{width:800px; height:120px;}
#footerTitle{float:right; font-size:15px; padding-top:20px; padding-right:20px;}
</style>
</head>
<body>
<div id="wrap">
<div id="header">
<div id="headerTitle">SIST Class4 </div>
</div>
<div id="container">
<!--
scope 속성들의 차이
page:기본 속성, 요청할 때마다 객체 생성되며, 생성된 객체는 현재페이지에서만 사용
request: 요청할때마다 객체 생성되며, 생성된 객체는 현재페이지와 forward로 이동한 페이지에서 사용 가능
session: 접속자마다 하나의 객체가 생성되며, 생성된 객체는 모든 JSP에서 사용할 수 있다. 접속을 끊으면 사라진다.
application: 최초 접속자에 의해 하나의 객체가 생성된다. 생성된 객체는 모든 JSP에서 모든 접속자가 사용한다.(공용)
Container가 종료되면 사라진다.
-->
<jsp:useBean id="c_vo" class="day0313.CounterVO" scope="application"/>
<jsp:setProperty property="cnt" name="c_vo" value="1"/>
안녕하세요?<br/>
이 페이지의 [<strong><jsp:getProperty property="cnt" name="c_vo"/></strong>] 번째 방문자입니다.
<div>
<%
String cnt = String.valueOf(c_vo.getCnt());
char temp=' ';
for(int i = 0; i < cnt.length(); i++){
temp=cnt.charAt(i);
%>
<img src="images/num_<%=temp %>.png" title="<%= temp %>"/>
<%
} // end for
%>
<%--<jsp:forward page="use_bean_scope.jsp">
<jsp:param name="cnt" value=request.getParameter("cnt")/> --%>
</div>
<div id="footer">
<div id="footerTitle"> copyright© all right reserved class4 </div>
</div>
</div>
</body>
</html> |
|
|
|
|
|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24 |
package day0313;
/**
* scope 속성에 따라 다르게 생성되는 객체
* @author owner
*/
public class CounterVO {
private int cnt;
public CounterVO(){
System.out.println("CounterVO");
}//counterVO
public int getCnt() {
return cnt;
}
//누적합이 되도록 대입연산자를 바꿔줌
public void setCnt(int cnt) {
this.cnt += cnt;
}
}//class
|
|
파란색은 예시
package test;
public class TestVO{
String name;
int age;
public TestVO(){
}
public void setName(String name){ //김희철
this.name=name;
}
public void setAge(int age){ //26
this.age=age;
}
public String getName(){
return name;
}
public int getAge(){
return age;
}
*객체 생성
<jsp:useBean id="객체명" class="패키지명.class명" scope="page"/>
<jsp:useBean id="tu" class="test.TestVO" scope="page"/>
useBean : 기본생성자를 사용해서만 객체화 한다.
scope={page, request, session, application}
scope : 생성된 객체사용 범위 설정
page : 기본설정
-
페이지가 요청될 때마다 객체 생성
-
생성된 객체는 해당페이지에서만 사용
request
-
페이지가 요청될 때마다 객체 생성
-
생성된 객체는 forward로 이동한페이지에서 사용
session
-
접속자의 정보를 서버측 메모리에 저장
-
페이지가 요청되면 접속브라우저를 구분하여 하나만 생성
-
모든 페이지에서 사용
-
접속자 브라우저를 식별하여 접속자마다 따로 사용
-
접속자의 브라우저가 종료되면 사라진다
application
-
최초 접속자에 의해 하나만 생성이 되고 모든 접속자가 하나의 객체를 사용
-
Container나 WAS가 종료되어야 사라진다
-
모든 페이지에서 사용할 수 있다
<사용>
setter method 호출
-
<jsp:setProperty name="객체명" property="set을 제외한 method명 소문자" value="값"/>
-
<jsp:setProperty name="tv" property="name" value="김희철"/>
-
<jsp:setProperty name="tv" property="age" value="27"/>
getter 호출
-
브라우저로 출력할 수 있다.
-
<jsp:getProperty name="객체명" property="get을 제외한 method명 소문자"/>
-
<jsp:getProperty name="tv" property="name"/>
-
<jsp:getProperty name="tv" property="age"/>
(주의점)
-
method명이 getMyName인 경우 myName 으로 쓴다.
-
첫단어는 모두 소문자로 쓰고 나머지는 대소문자를 구별한다.
*Web parameter처리
-
주의 : HTML Form Control 이름과 VO의 인스턴스 변수명 반드시 같아야 한다.
-
jsp에서 객체를 생성하고
-
<jsp:useBean id="객체명" class="패키지명.class" value="값"/>
-
setter호출
-
<jsp:setProperty name="객체명" property="*"/> *을 걸면 알아서 form control과 매칭되는 걸 모두 찾아줌
http://tomcat.apache.org/ 에서 Taglibs새로 다운
1.1 버전 다운로드
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203 |
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>회원가입</title>
<link rel="stylesheet" type="text/css" href="http://localhost:8080/html/common/css/main_v190130.css"/>
<style type="text/css">
#joinTitle{ font-weight: bold; font-size: 20px; }
.tdAlign{ text-align: center }
table{ margin: 0px auto }
tr{ height: 25px}
#wrap{ width: 1007px; margin:0px auto }
#joinHeader{ width: 1007px; height: 195px;
background: #FFFFFF url(images/header.png) no-repeat; }
.span{ color: #FF0000 }
</style>
<script type="text/javascript">
$(function(){
//옵션 생성
//년
var obj=document.joinFrm;
var b_year=obj.b_year; //select얻기
var date=new Date();
var year_idx=0;
//20살의 나이를 가진 년도에 selected
var flag_year=date.getFullYear()-20+1;
for(var i=1950; i< date.getFullYear()+1; i++ ){
//2. select의 옵션을 생성 Option(보여질값 , value값)
b_year.options[year_idx]=new Option(i, i);
if(flag_year == i){
b_year.selectedIndex = year_idx;
}//end if
year_idx++;
}//end for
//월 설정 1 ~ 12
var b_month=obj.b_month;
var month_idx=0;
for(var i= 1 ; i < 13 ; i++){
b_month.options[month_idx]=new Option(i,i);
month_idx++;
}//end for
//일 설정 1 ~ 31
var b_day=obj.b_day;
var day_idx=0;
for(var i= 1 ; i < 32 ; i++){
b_day.options[day_idx]=new Option(i,i);
day_idx++;
}//end for
$("#btnJoin").click(function(){
$("#joinFrm").submit();
});//click
});//ready
</script>
</head>
<body>
<div id="wrap">
<div id="joinHeader"></div>
<div id="joinContent">
<form action="bean_param.jsp" name="joinFrm" id="joinFrm" method="post">
<table>
<tr>
<td class="tdAlign" colspan="2"><span id="joinTitle">UseBean 사용 회원가입</span></td>
</tr>
<tr>
<td><span class="span">*</span>아이디</td>
<td>
<input type="text" class="inputBox" name="id" style="width:100px">
</td>
</tr>
<tr>
<td><span class="span">*</span>비밀번호</td>
<td><input type="password" class="inputBox" name="pass1" style="width:120px"></td>
</tr>
<tr>
<td><span class="span">*</span>비밀번호 확인</td>
<td><input type="password" class="inputBox" id="pass2" name="pass2" style="width:120px"></td>
</tr>
<tr>
<td><span class="span">*</span>이름</td>
<td><input type="text" class="inputBox" name="name" style="width:120px"></td>
</tr>
<tr>
<td><span class="span">*</span>주민번호</td>
<td><input type="text" class="inputBox" name="ssn1" id="ssn1" style="width:60px" maxlength="6"><label> - </label>
<input type="password" class="inputBox" name="ssn2" id="ssn2" style="width:70px" maxlength="7"></td>
</tr>
<tr>
<td> 성별</td>
<td><input type="radio" value="남자" name="gender">남자
<input type="radio" value="여자" name="gender">여자</td>
</tr>
<tr>
<td> 생년월일</td>
<td>
<select name="b_year" class="inputBox">
</select>
<label>년</label>
<select name="b_month" class="inputBox">
</select>
<label>월</label>
<select name="b_day" class="inputBox">
</select>
<label>일</label>
</td>
</tr>
<tr>
<td> 나이</td>
<td><input type="text" name="age" class="inputBox" style="width:30px"></td>
</tr>
<tr>
<td> 관심언어</td>
<td>
<input type="checkbox" value="Java" name="interestlang">Java
<input type="checkbox" value="C/C++" name="interestlang">C/C++
<input type="checkbox" value="Python" name="interestlang">Python
<input type="checkbox" value="VB" name="interestlang">VB
<br>
<input type="checkbox" value="JSP" name="interestlang">JSP
<input type="checkbox" value="Servlet" name="interestlang">Servlet
<input type="checkbox" value="ASP" name="interestlang">ASP
<input type="checkbox" value="php" name="interestlang">php
</td>
</tr>
<tr>
<td> 결혼여부</td>
<td><input type="radio" value="미혼" name="marrigeFlag" checked="checked" >미혼
<input type="radio" value="기혼" name="marrigeFlag">기혼</td>
</tr>
<tr>
<td> 결혼기념일</td>
<td><input type="text" maxlength="4" name="m_year" style="width:40px" class="inputBox">년
<input type="text" maxlength="2" name="m_month" style="width:20px" class="inputBox">월
<input type="text" maxlength="2" name="m_day" style="width:20px" class="inputBox">일</td>
</tr>
<tr>
<td><span class="span">*</span>우편번호</td>
<td><input type="text" id="zipcode" name="zipcode" style="width:50px" class="inputBox" >
<button type="button" class="btn" id="daumZip">우편번호검색</button></td>
</tr>
<tr>
<td><span class="span">*</span>주소</td>
<td>
<input type="text" id="roadAddr" name="addr1" style="width:250px" class="inputBox">
참고 주소 : <input type="text" id="extraAddress" class="inputBox"/>
</td>
</tr>
<tr >
<td><span class="span">*</span>상세주소</td>
<td><input type="text" class="inputBox" name="addr2" style="width:250px"></td>
</tr>
<tr valign="middle">
<td> 가입인사</td>
<td><textarea name="greetings" style="width:250px;height: 100px" class="inputBox"></textarea></td>
</tr>
<tr>
<td colspan="2" class="tdAlign" >
<button type="button" class="btn" id="btnJoin">가입</button>
<button type="reset" class="btn">초기화</button></td>
</tr>
<tr>
<td colspan="2"> <span class="span">*표는 필수 입력사항.</span></td>
</tr>
</table>
</form>
</div>
</div>
</body>
</html>
|
|
|
|
|
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85 |
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"
info="Web Parameter를 useBean action tag로 처리하는 방법."
%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<link rel="stylesheet" type="text/css" href="http://localhost:8080/jsp_prj/common/css/main_v190130.css"/>
<style type="text/css">
/* wrap에 background-color를 넣고 header, container, footer에도 background-color를 넣어 가려지는지 확인 */
#wrap{margin:0px auto; width:800px; height:860px;}
/* wrap안쪽 디자인들은 wrap안에 들어있기 때문에 width안줘도 자동으로 800이 됨 */
#header{width:800px; height:140px; background: #FFFFFF url(http://localhost:8080/jsp_prj/common/images/header_bg.png) repeat-x;
position:relative;}
#headerTitle{ font-family: HY견고딕, 고딕; font-size:35px; font-weight:bold; text-align:center;
position:absolute; top:40px; left:290px;}
#container{width:800px; height:600px;}
#footer{width:800px; height:120px;}
#footerTitle{float:right; font-size:15px; padding-top:20px; padding-right:20px;}
</style>
</head>
<body>
<div id="wrap">
<div id="header">
<div id="headerTitle">SIST Class4 </div>
</div>
<div id="container">
<!-- HTML Form Contorl의 값 받기 . 값의 사용범위를 생각하여 scope에 값 입력 -->
<!--useBean을 쓰면 request.getParameter를 쓰지 않고도 접속자가 입력하는 값을 다 쓸 수 있다. -->
<% request.setCharacterEncoding("UTF-8"); %>
<!-- 1. Bean 생성 -->
<jsp:useBean id="bp_vo" class="day0313.BeanParamVO" scope="page"/>
<!-- 2. setter method를 불러서 값을 저장 -->
<jsp:setProperty property="*" name="bp_vo"/>
<%-- <%=bp_vo %>--%>
<table>
<tr>
<td colspan="2">입력하신 정보는 아래와 같습니다.</td>
</tr>
<tr>
<td>아이디</td>
<td><jsp:getProperty property="id" name="bp_vo"/></td>
</tr>
<tr>
<td>이름</td>
<td><jsp:getProperty property="name" name="bp_vo"/></td>
</tr>
<tr>
<td>생년월일</td>
<!--숫자로 변환되어 저장된 값 -->
<td><jsp:getProperty property="b_year" name="bp_vo"/>-
<jsp:getProperty property="b_month" name="bp_vo"/>-
<jsp:getProperty property="b_day" name="bp_vo"/>
(만 <%=2019-bp_vo.getB_year() %>세)
</td>
</tr>
<tr>
<td>관심언어</td>
<!-- 로 막으면 소스보기에 뜨기 때문에 <%-- --%>로 주석 달아줘야 한다. -->
<%-- <td><jsp:getProperty property="interestlang" name="bp_vo"/></td> --%>
<td>
<%
String[] lang=bp_vo.getinterestlang();
if(lang!=null){
for(int i=0; i<lang.length; i++){
out.print(lang[i]);
out.println(" ");
}//end for
}else{
out.println("관심언어 없음");
}//end else
%>
</tr>
</table>
</div>
<div id="footer">
<div id="footerTitle"> copyright© all right reserved class4 </div>
</div>
</div>
</body>
</html> |
|
|
|
|
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140 |
package day0313;
import java.util.Arrays;
/**
* HTML Form Control의 이름과 VO에 instance 변수명이 반드시 같아야 한다.
* @author owner
*/
public class BeanParamVO {
private String id, pass1, name, ssn1, ssn2, gender,
marriageFlag, m_year, m_month, m_day, zipcode, addr1, addr2, greetings;
private int b_year, b_month, b_day, age;
private String[] interestlang;
public String getId() {
return id;
}
public String getPass1() {
return pass1;
}
public String getName() {
return name;
}
public String getSsn1() {
return ssn1;
}
public String getSsn2() {
return ssn2;
}
public String getGender() {
return gender;
}
public String getMarriageFlag() {
return marriageFlag;
}
public String getM_year() {
return m_year;
}
public String getM_month() {
return m_month;
}
public String getM_day() {
return m_day;
}
public String getZipcode() {
return zipcode;
}
public String getAddr1() {
return addr1;
}
public String getAddr2() {
return addr2;
}
public String getGreetings() {
return greetings;
}
public int getB_year() {
return b_year;
}
public int getB_month() {
return b_month;
}
public int getB_day() {
return b_day;
}
public int getAge() {
return age;
}
public String[] getinterestlang() {
return interestlang;
}
public void setId(String id) {
this.id = id;
}
public void setPass1(String pass1) {
this.pass1 = pass1;
}
public void setName(String name) {
this.name = name;
}
public void setSsn1(String ssn1) {
this.ssn1 = ssn1;
}
public void setSsn2(String ssn2) {
this.ssn2 = ssn2;
}
public void setGender(String gender) {
this.gender = gender;
}
public void setMarriageFlag(String marriageFlag) {
this.marriageFlag = marriageFlag;
}
public void setM_year(String m_year) {
this.m_year = m_year;
}
public void setM_month(String m_month) {
this.m_month = m_month;
}
public void setM_day(String m_day) {
this.m_day = m_day;
}
public void setZipcode(String zipcode) {
this.zipcode = zipcode;
}
public void setAddr1(String addr1) {
this.addr1 = addr1;
}
public void setAddr2(String addr2) {
this.addr2 = addr2;
}
public void setGreetings(String greetings) {
this.greetings = greetings;
}
public void setB_year(int b_year) {
this.b_year = b_year;
}
public void setB_month(int b_month) {
this.b_month = b_month;
}
public void setB_day(int b_day) {
this.b_day = b_day;
}
public void setAge(int age) {
this.age = age;
}
public void setinterestlang(String[] interestlang) {
this.interestlang = interestlang;
}
@Override
public String toString() {
return "BeanParamVO [id=" + id + ", pass1=" + pass1 + ", name=" + name + ", ssn1=" + ssn1 + ", ssn2=" + ssn2
+ ", gender=" + gender + ", marriageFlag=" + marriageFlag + ", m_year=" + m_year + ", m_month="
+ m_month + ", m_day=" + m_day + ", zipcode=" + zipcode + ", addr1=" + addr1 + ", addr2=" + addr2
+ ", greetings=" + greetings + ", b_year=" + b_year + ", b_month=" + b_month + ", b_day=" + b_day
+ ", age=" + age + ", interestlang=" + Arrays.toString(interestlang) + "]";
}
}//class
|
|
|
|
|
*JSTL(jsp Standard Tag Library)
-
액션태그(표준액션)를 sun사가 아닌 외부개발자가 제작하여 배포하는 것
-
OGNL(Object Graphic Navigation Language)
-
태그를 정의하면 태그에 따른 문장을 찾아서 변환한 후 실행하는 언어
-
Markup 언어의 형식
-
core, fmt, sql, xml 등 지원
-
core: 변수관련, 제어문 관련(if/for), 예외처리, 페이지 삽입(import/include) 지원
-
fmt : decimal Format, SimpleDateFormat 등 날짜, 숫자 형식의 변환
-
Apache에서 제작하고 배포하는 library로 WEB-INF\lib 폴더에 배포되는 jar(standard.jar, jstl.jar)를 설치하여 사용
-
사용법
필요한 jsp에서 지시자를 선언
<%@ taglib prefix=" " uri="http://java.sun.com/jsp/jstl/core 또는 fmt"%>
-
태그 사용
<prefix:지원태그명 속성="값" ..></prefix:지원태그명>
<prefix:태그명 속성명="값"..../>
반응형
'국비지원학원 > JSP' 카테고리의 다른 글
98일차-JSP_JSTL_forTokens (0) | 2019.04.03 |
---|---|
97일차-JSP_JSTL(Jsp Standard Tag Library) (0) | 2019.04.03 |
95일차-JSP_내장 객체 (0) | 2019.03.31 |
94일차-JSP tag's (0) | 2019.03.27 |
93일차-JSP (0) | 2019.03.26 |