Just Do It

JSP의 Object

by 핫도구
반응형

Web 어플리케이션의 기본 객체(implicit object) 이다.
servlet에서 선언을 했던 과거와 다르게 JSP에서 별도의 인스턴스 선언 없이 사용이 가능하다.
request, response, out, session, pageContext, application 등 9가지가 존재한다.

<h3>1. request </h3>
ContextPath = <%=request.getContextPath()%>
RealPath = <%=request.getRealPath("/")%>
RequestURL = <%=request.getRequestURL() %>
RequestURI = <%=request.getRequestURI() %>
RequestServletPath = <%=request.getServletPath() %>

<h3>2. session </h3>
sessionId = <%=session.getId()%>

<h3>3. out </h3>
out = <%= out.print("out객체 출력);%>

<h3>4. pageContext</h3>
JSP 페이지에 대한 정보를 저장한다.
PageScope에 해당하는 객체
기본 객체를 return하는 메서드를 제공한다.
 - request객체와 메서드가 return하는 개체와 동일성을 비교해보면
 <% HttpServletRequest req = (HttpServletRequest)pageContext.getRequest(); %>
 비교결과 : <%= request = req%>
 pageContext가 제공하는 out객체로 출력하기 = <% pageContexst.getOut().print("pageContext가 제공하는 out 객체 출력"); %>
 
 <h3> 5. application </h3>
 서버정보 = <%=application.getServerInfo() %>
 servlet 메이저 버전 = <%= application.getMajorVersion() %>
 servlet 마이너 버전 = <%= application.getMinorVersion() %>
 RealPath1 = <%= application.getRealPath("") %>  // "" 사용시 현 프로젝트의 실행중인 realPath를 반환
 RealPath2 = <%= application.getRealPath("/jsp1") %> // 지정한 경로의 realpath를 return

 

를 확인할 수 있다.

반응형

'JAVA > OLD' 카테고리의 다른 글

EL_Basic  (0) 2024.08.18
JSP_PageFlow  (0) 2024.08.18
JSP  (0) 2024.08.16
Login & Logout  (0) 2024.08.16
Scope를 활용한 값 보관 및 사용  (0) 2024.08.16

블로그의 정보

AquaMan

핫도구

활동하기