Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
Tags
- 기본
- Graphic
- 생성자
- 이클립스
- 오버로딩
- struts2
- 메소드
- mybatis
- 클래스
- AWT
- 배열
- Menu
- 안드로이드
- oracle
- 어노테이션
- OGNL
- 예외처리
- Java
- Spring
- JSP
- paint
- JavaScript
- layout
- HTML
- 전화걸기
- Eclips
- 국제화
- Android
- 메서드
- 에러페이지
Archives
- Today
- Total
note
JSP 기본 객체와 영역 본문
Page,Request,Session
a.jsp 실행화면
a.jsp -> b.jsp 로 변경후 이동
b.jsp 실행화면
a.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
JSP <span class="hljs-number">4</span>개 영역 및 기본객체 사용
<%
pageContext.setAttribute("season","봄");
String season = (String)pageContext.getAttribute("season");
request.setAttribute("season1", "여름");
String season1 = (String)request.getAttribute("season1");
session.setAttribute("season2", "가을");
String season2 = (String)session.getAttribute("season2");
%>
page영역 : <%=season %>
Request영역 : <%=season1 %>
session영역 : <%=season2 %>
b.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
JSP <span class="hljs-number">4</span>개 영역 및 기본객체 사용
<%
String season = (String)pageContext.getAttribute("season");
String season1 = (String)request.getAttribute("season1");
String season2 = (String)session.getAttribute("season2");
%>
page영역 : <%=season %>
request영역 : <%=season1 %>
session영역 : <%=season2 %>
Application
setApplicationAttribute.jsp
setApplicationAttribute.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%
String name = "id";
String value = "dragon";
application.setAttribute(name, value);
%>
application 속성 지정
application 기본 객체의 속성 설정 :
<%=name %> = <%= value %>
viewApplicationAttribute.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ page import="java.util.Enumeration" %>
application 기본 객체 속성 보기
<%
Enumeration attrEnum = application.getAttributeNames();
while(attrEnum.hasMoreElements()){
String name = (String)attrEnum.nextElement();
Object value = application.getAttribute(name);
%>
application 속성 : <%=name %> = <%=value %>
<%} %>
Application 사용시 주의사항
데이터 보관시 동기화 문제가 생김
Client를 구분하지 못하므로
Application은 다 공유할 수 있는 정보를 저장시키는데 사용함
자신이 저장한 데이터를 다른 클라이언트가 가져갈 수 있음
'JSP > 기본' 카테고리의 다른 글
JSP include (0) | 2012.02.07 |
---|---|
<jsp:include> 액션 태그를 사용하여 페이지 모듈화 (0) | 2012.02.06 |
JSP 기본 객체 사용하여 자원 읽기 (0) | 2012.02.06 |
Servlet Context (0) | 2012.02.06 |
JSP 서버정보 출력, 로그 메세지 기록 (0) | 2012.02.06 |