728x90
====================
application 오브젝트
====================

application 내장 객체는 서블릿 또는 어플리케이션 외부환경정보(context)를 나타내는 내장 객체이다

application 객체는 javax.servlet.Servletcontext 객체 타입으로 제공된다
 
---------------------------------
메소드                       설명
---------------------------------
 String  getServerInfo()   서버정보를 구한다.( 웹 컨테이너 이름과 버전 리턴,JSP컨테이너에 대한 정보 )

 String getMimeType(fileName)  지정한 파일의 MIME 타입을 리턴한다

    String fn= request.getParameter("filename");
    String contentType = application.getMimeType(fn);


 String getMajorVersion()  서버가 지원하는 서블릿규약의 메이저 버전을 리턴한다.(정수부분)

 String getMinorVersion()  서버가 지원하는 서블릿규약의 마이너 버전을 리턴한다.(소수부분)

 String getRealPath(url) - 지정된 url 실제 경로 알아내기
 
 void  log(message)    - message 내용을 파일에 기록하기  ( C:\Tomcat 5.0\logs 에 저장 )
                         로그 파일에 메세지를 기록한다 

-----에제-* application.jsp---------------------------------------
<%@ page
contentType="text/html;charset=euc-kr"
import="java.io.*"
%>

<html>
	<body>
		<%
		String serverInfo=application.getServerInfo();
                String mimeType=application.getMimeType("RequestTest.jsp");
		String realPath=application.getRealPath("/");
		
		int major=application.getMajorVersion();
		int minor=application.getMinorVersion();
		
		application.log("로그기록");
		
		%>
		서버 정보: <%= serverInfo %><br>
                MIME Type : <%= mimetype%>
		도큐먼트루트의 실제 경로: <%= realPath %><br>

		major 버전 :<%= major%><br>
		minor 버전 :<%= minor%><br>

	</body>
</html>


===========================================================================
pageContext 내장 객체
---------------------------------------------------------------------------

pageContext 객체는 현재 JSP페이지의 context를 나타내며

pageContext내부 객체를 통해서 다른 내부 객체에 접근할 수 있다 


예를 들어 out 내장 객체를 구하고자 할 경우의 코드는 다음과 같다 
JspWriter pageOut=pageContext.getOut();


----------------------------------------------------------------------------
리턴형                메서드                           설명
----------------------------------------------------------------------------
ServletRequest   getRequest()           request 기본객체를 구한다.

ServletResponse  getResponse()           response 기본객체를 구한다.

JspWriter            getOut()                 out 기본객체를 구한다.


HttpSession      getSession()           session 기본객체를 구한다.

                                        요청한 클라이언트의 세션 정보를 담고 있는 객체를 반환 


ServletContext    getServletContext()    application 기본객체를 구한다.

                                        페이지에 대한 서블릿 실행 환경 정보를 담고 있는 객체를 반환 


ServletConfig    getServletConfig()     config 기본객체를 구한다.

                                        페이지의 서블릿 초기정보의 설정 정보를 담고 있는 객체를 반환 


Exception      getException()            exception 기본객체를 구한다.

Object         getPage()                  page 기본객체를 구한다.




================================================================================
config  내장 객체  (javax.servlet.ServletConfig)
---------------------------------------------------------------------------------

Enumeration  getInitParameterNames()   모든 초기 파라미터 이름을 리턴

String    getInitParameter(name)     이름이 name인 초기 파라미터의 값 리턴

String   getServletName()         서블릿의 이름을 리턴

ServletContext getServletConfig()   실행하는 서블릿 ServletContext 객체를 리턴

=====예제 ======

<%= config.getServletName()%><p>
<%= config.getServletContext()%><p>

출력결과
jsp
org.apache.catalina.core.ApplicationContextFacade@e41d4a


=====================================================================
page 내장 객체 : 

jsp 객체는 JSP페이지 그 자체를 나타내는 객체이다 

그래서 this 키워드로 자기 자신을 참조할 수 있다 

javax.servlet.jsp.HttpJspPage 클래스 타입으로 제공하는 JSP 내부 객체이다 
---------------------------------------------------------------------
메서드 

getServletInfo() :info 속성값을 얻어낸다
 
=====예제 ======

<%@ page info="예제"%>

<h2> page 내장 객체</h2>

현재 페이지에 대한 정보 :
<%= this.getServletInfo()%>


<h2> config  내장 객체 </h2>

<%= config.getServletName()%><p>
<%= config.getServletContext()%><p>


<h2> pageContext  내장 객체 </h2>

요청 : <%= pageContext.getRequest()%><p>

세션 : <%= pageContext.getSession()%><p>

예외 : <%= pageContext.getException()%><p>


======================================================================
exception  내장 객체 

exeption 내부 객체는 프로그래머가 JSP페이지에서 발생한 예외를 처리하는 

페이지를 지정한 경우 에러 페이지에 전달되는 예외 객체이다 

----------------------------------------------------------------------

String getMessage()         발생된 예외 메시지를 리턴한다

String toString()           발생된 예외 클래스명과 메세지 리턴

String printStackTrace()    발생된 예외를 역추척하기 위해 표준 예외 스트림을 출력한다

+ Recent posts