본문 바로가기

개발하자/JSP&Servlet

application,session,request,pageContext

a.jsp
=====
<%@ page language="java" contentType="text/html; charset=EUC-KR"
pageEncoding="EUC-KR"%>
<%
application.setAttribute("ap","apV");    //톰캣끄기전까지는 주소유지됨
session.setAttribute("se","seV");        //웹브라우져가 닫히면 사라짐
request.setAttribute("re","reV");            //주소창에 다른거 입력하면 사라짐
pageContext.setAttribute("pa","paV");    //다음페이지로 가면 주소달라짐
%>
<%=application.getAttribute("ap")%><br>
<%=session.getAttribute("se")%><br>
<%=request.getAttribute("re")%><br>
<%=pageContext.getAttribute("pa")%><br>
<a href="b.jsp">요청</a>


b.jsp
=====
<%@ page language="java" contentType="text/html; charset=EUC-KR"
pageEncoding="EUC-KR"%>
<%=application.getAttribute("ap")%><br>
<%=session.getAttribute("se")%><br>
<%=request.getAttribute("re")%><br>
<%=pageContext.getAttribute("pa")%><br>